From 632425518498309e0b1b7909f5a9bfd9a6ad1aca Mon Sep 17 00:00:00 2001 From: Jerome Etienne Date: Sat, 29 Jul 2017 12:18:58 +0100 Subject: [PATCH] more work --- TODO.md | 46 +- aframe/Makefile | 14 +- aframe/build/aframe-ar.js | 553 ++++++++++++++++-- aframe/build/aframe-ar.min.js | 8 +- aframe/examples/aframe-session.html | 12 +- three.js/build/ar.js | 124 ++-- three.js/build/ar.min.js | 4 +- three.js/examples/arjs-session.html | 23 +- three.js/src/newAPI/arjs-anchor.js | 13 +- three.js/src/newAPI/arjs-hittester.js | 45 +- three.js/threex-hittester-plane.js | 51 ++ three.js/threex-hittester-tango.js | 33 ++ .../build/artoolkit-webvr-polyfill.js | 124 ++-- .../build/artoolkit-webvr-polyfill.min.js | 4 +- 14 files changed, 848 insertions(+), 206 deletions(-) create mode 100644 three.js/threex-hittester-plane.js create mode 100644 three.js/threex-hittester-tango.js diff --git a/TODO.md b/TODO.md index 40b8859..57c0048 100644 --- a/TODO.md +++ b/TODO.md @@ -1,42 +1,43 @@ ## New API - aframe - - honor marker preset - artoolkit modelViewMatrix/cameraTransformMatrix works -- area-artoolkit fails in cameraTransformMatrix - - wtf ??? so issue upstream ? how to reproduce in three.js - -- aruco got perspective issue - likely camera init +- put multi-markers in /src/markers-area + - /examples/markers-area/ - here all the examples + - put marker page in this directory too + - three.js/examples/multi-markers/\*.js in /src/markers-area +- refactor threex-screenasportal as a demo in /examples/markers-area/demo-screen-as-portal + - this is not a threex - tango video fails - some post processing in aframe.js - https://github.com/wizgrav/aframe-effects/blob/master/systems/effects.js - it seems to override renderer.render by its own function... not super clean but if it works ok - it can be changed later - - tango tracking is working ? i think so - - test in both mode + - test in both mode - tracking only tho, clearly no video -- DONE remove arSession.onResize2() - thus the API is cleaner - - do a onResize with a test on argument.length - if not good number call old stuff -- DONE put the UI in the plugin - - do a special function for it, and call this function from javascript - - or more like a data in the system +- LATER aruco got perspective issue - likely camera init + ## New API -- build a aframe version of that to see how it fit - - when api is stable enougth ? - - when all the bugs are sorted out - - currently only something about displaying point cloud in tango - very minor +- clickability works IIF changeMatrixMode === modelViewMatrix + - change that + - not a bug, it is just not implemented + - arjs-hittester and threex-arclickability are messy + - clean those 2. no need for 2 class ? + - which API will remain + - hittester-plane + - hittester-tango + - replace ARClickability with something better and port arjs-hittester on top - Check it works on all cases - no special cases incompatibilities - changeMatrixMode - tango point cloud fails in cameraTransformMatrix -- move three.js/arjs-.js in three.js/src/newApi/ - later rename file/class - move all THREEx for ar.js as ARjs. - remove artoolkit in the name when it is multi backend @@ -53,6 +54,17 @@ - arkit - best +- DONE area-artoolkit fails in cameraTransformMatrix + - wtf ??? so issue upstream ? how to reproduce in three.js + - is the error in three.js level, or aframe level + - apparently setting cameraTransformMatrix or modelViewMatrix in changeMatrixMode doesnt change a thing in area-artoolkit + - area-artoolkit seems to react as if it was always modelViewMatrix +- DONE remove arSession.onResize2() - thus the API is cleaner + - do a onResize with a test on argument.length - if not good number call old stuff +- DONE put the UI in the plugin + - do a special function for it, and call this function from javascript + - or more like a data in the system +- DONE move three.js/arjs-.js in three.js/src/newApi/ - DONE pick real world with all trackingMethod - hit tester with plane - DONE button tangoonly pointcloudtoggle diff --git a/aframe/Makefile b/aframe/Makefile index 61f96f2..b1dd12a 100644 --- a/aframe/Makefile +++ b/aframe/Makefile @@ -5,6 +5,7 @@ watch: build build: cat ../three.js/threex*.js \ ../three.js/examples/multi-markers/threex*.js \ + ../three.js/src/newAPI/*.js \ aframe-ar.js \ ../three.js/vendor/jsartoolkit5/build/artoolkit.min.js \ ../three.js/vendor/jsartoolkit5/js/artoolkit.api.js \ @@ -12,16 +13,3 @@ build: minify: build uglifyjs build/aframe-ar.js > build/aframe-ar.min.js - -##### - -build0: - cat ../three.js/threex*.js \ - ../three.js/examples/multi-markers/threex*.js \ - aframe-ar.js \ - ../three.js/vendor/jsartoolkit5/build/artoolkit.min.js \ - ../three.js/vendor/jsartoolkit5/js/artoolkit.api.js \ - > build/aframe-ar0.js - -minify0: build0 - uglifyjs build/aframe-ar0.js > build/aframe-ar0.min.js diff --git a/aframe/build/aframe-ar.js b/aframe/build/aframe-ar.js index 0a27b96..aea35fb 100644 --- a/aframe/build/aframe-ar.js +++ b/aframe/build/aframe-ar.js @@ -772,9 +772,10 @@ THREEx.ArSmoothedControls.prototype.update = function(targetObject3d){ object3d.scale.lerp(targetObject3d.scale, parameters.lerpScale) } } +var ARjs = ARjs || {} var THREEx = THREEx || {} -THREEx.ArToolkitContext = function(parameters){ +ARjs.Context = THREEx.ArToolkitContext = function(parameters){ var _this = this _this._updatedAt = null @@ -791,7 +792,7 @@ THREEx.ArToolkitContext = function(parameters){ matrixCodeType: '3x3', // url of the camera parameters - cameraParametersUrl: THREEx.ArToolkitContext.baseURL + 'parameters/camera_para.dat', + cameraParametersUrl: ARjs.Context.baseURL + 'parameters/camera_para.dat', // tune the maximum rate of pose detection in the source image maxDetectionRate: 60, @@ -841,12 +842,12 @@ THREEx.ArToolkitContext = function(parameters){ } } -Object.assign( THREEx.ArToolkitContext.prototype, THREE.EventDispatcher.prototype ); +Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype ); -// THREEx.ArToolkitContext.baseURL = '../' +// ARjs.Context.baseURL = '../' // default to github page -THREEx.ArToolkitContext.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/' -THREEx.ArToolkitContext.REVISION = '1.0.1-dev' +ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/' +ARjs.Context.REVISION = '1.0.1-dev' @@ -855,7 +856,7 @@ THREEx.ArToolkitContext.REVISION = '1.0.1-dev' * @param {string} trackingBackend - the tracking to user * @return {THREE.Camera} the created camera */ -THREEx.ArToolkitContext.createDefaultCamera = function( trackingBackend ){ +ARjs.Context.createDefaultCamera = function( trackingBackend ){ console.assert(false, 'use ARjs.Utils.createDefaultCamera instead') // Create a camera if( trackingBackend === 'artoolkit' ){ @@ -872,7 +873,7 @@ THREEx.ArToolkitContext.createDefaultCamera = function( trackingBackend ){ ////////////////////////////////////////////////////////////////////////////// // init functions ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype.init = function(onCompleted){ +ARjs.Context.prototype.init = function(onCompleted){ var _this = this if( this.parameters.trackingBackend === 'artoolkit' ){ this._initArtoolkit(done) @@ -898,7 +899,7 @@ THREEx.ArToolkitContext.prototype.init = function(onCompleted){ //////////////////////////////////////////////////////////////////////////////// // update function //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype.update = function(srcElement){ +ARjs.Context.prototype.update = function(srcElement){ // be sure arController is fully initialized if(this.parameters.trackingBackend === 'artoolkit' && this.arController === null) return false; @@ -939,12 +940,12 @@ THREEx.ArToolkitContext.prototype.update = function(srcElement){ //////////////////////////////////////////////////////////////////////////////// // Add/Remove markerControls //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype.addMarker = function(arMarkerControls){ +ARjs.Context.prototype.addMarker = function(arMarkerControls){ console.assert(arMarkerControls instanceof THREEx.ArMarkerControls) this._arMarkersControls.push(arMarkerControls) } -THREEx.ArToolkitContext.prototype.removeMarker = function(arMarkerControls){ +ARjs.Context.prototype.removeMarker = function(arMarkerControls){ console.assert(arMarkerControls instanceof THREEx.ArMarkerControls) // console.log('remove marker for', arMarkerControls) var index = this.arMarkerControlss.indexOf(artoolkitMarker); @@ -955,7 +956,7 @@ THREEx.ArToolkitContext.prototype.removeMarker = function(arMarkerControls){ ////////////////////////////////////////////////////////////////////////////// // artoolkit specific ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype._initArtoolkit = function(onCompleted){ +ARjs.Context.prototype._initArtoolkit = function(onCompleted){ var _this = this // set this._artoolkitProjectionAxisTransformMatrix to change artoolkit projection matrix axis to match usual webgl one @@ -1026,7 +1027,7 @@ THREEx.ArToolkitContext.prototype._initArtoolkit = function(onCompleted){ /** * return the projection matrix */ -THREEx.ArToolkitContext.prototype.getProjectionMatrix = function(srcElement){ +ARjs.Context.prototype.getProjectionMatrix = function(srcElement){ // FIXME rename this function to say it is artoolkit specific - getArtoolkitProjectMatrix @@ -1049,14 +1050,14 @@ THREEx.ArToolkitContext.prototype.getProjectionMatrix = function(srcElement){ return projectionMatrix } -THREEx.ArToolkitContext.prototype._updateArtoolkit = function(srcElement){ +ARjs.Context.prototype._updateArtoolkit = function(srcElement){ this.arController.process(srcElement) } ////////////////////////////////////////////////////////////////////////////// // aruco specific ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype._initAruco = function(onCompleted){ +ARjs.Context.prototype._initAruco = function(onCompleted){ this.arucoContext = new THREEx.ArucoContext() // honor this.parameters.canvasWidth/.canvasHeight @@ -1077,7 +1078,7 @@ THREEx.ArToolkitContext.prototype._initAruco = function(onCompleted){ } -THREEx.ArToolkitContext.prototype._updateAruco = function(srcElement){ +ARjs.Context.prototype._updateAruco = function(srcElement){ // console.log('update aruco here') var _this = this var arMarkersControls = this._arMarkersControls @@ -1105,7 +1106,7 @@ THREEx.ArToolkitContext.prototype._updateAruco = function(srcElement){ ////////////////////////////////////////////////////////////////////////////// // tango specific ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype._initTango = function(onCompleted){ +ARjs.Context.prototype._initTango = function(onCompleted){ var _this = this // check webvr is available if (navigator.getVRDisplays){ @@ -1148,7 +1149,7 @@ THREEx.ArToolkitContext.prototype._initTango = function(onCompleted){ } -THREEx.ArToolkitContext.prototype._updateTango = function(srcElement){ +ARjs.Context.prototype._updateTango = function(srcElement){ // console.log('update aruco here') var _this = this var arMarkersControls = this._arMarkersControls @@ -1201,7 +1202,6 @@ THREEx.ArToolkitContext.prototype._updateTango = function(srcElement){ } var ARjs = ARjs || {} - var THREEx = THREEx || {} /** @@ -1377,32 +1377,59 @@ ARjs.Profile.prototype.checkIfValid = function () { } return this } +var ARjs = ARjs || {} var THREEx = THREEx || {} -THREEx.ArToolkitSource = function(parameters){ +ARjs.Source = THREEx.ArToolkitSource = function(parameters){ + var _this = this + + this.ready = false + this.domElement = null + // handle default parameters this.parameters = { // type of source - ['webcam', 'image', 'video'] - sourceType : parameters.sourceType !== undefined ? parameters.sourceType : 'webcam', + sourceType : 'webcam', // url of the source - valid if sourceType = image|video - sourceUrl : parameters.sourceUrl !== undefined ? parameters.sourceUrl : null, + sourceUrl : null, // resolution of at which we initialize in the source image - sourceWidth: parameters.sourceWidth !== undefined ? parameters.sourceWidth : 640, - sourceHeight: parameters.sourceHeight !== undefined ? parameters.sourceHeight : 480, + sourceWidth: 640, + sourceHeight: 480, // resolution displayed for the source - displayWidth: parameters.displayWidth !== undefined ? parameters.displayWidth : 640, - displayHeight: parameters.displayHeight !== undefined ? parameters.displayHeight : 480, + displayWidth: 640, + displayHeight: 480, } + ////////////////////////////////////////////////////////////////////////////// + // setParameters + ////////////////////////////////////////////////////////////////////////////// + setParameters(parameters) + function setParameters(parameters){ + if( parameters === undefined ) return + for( var key in parameters ){ + var newValue = parameters[ key ] - this.ready = false - this.domElement = null + if( newValue === undefined ){ + console.warn( "THREEx.ArToolkitSource: '" + key + "' parameter is undefined." ) + continue + } + + var currentValue = _this.parameters[ key ] + + if( currentValue === undefined ){ + console.warn( "THREEx.ArToolkitSource: '" + key + "' is not a property of this material." ) + continue + } + + _this.parameters[ key ] = newValue + } + } } ////////////////////////////////////////////////////////////////////////////// // Code Separator ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.init = function(onReady, onError){ +ARjs.Source.prototype.init = function(onReady, onError){ var _this = this if( this.parameters.sourceType === 'image' ){ @@ -1438,7 +1465,7 @@ THREEx.ArToolkitSource.prototype.init = function(onReady, onError){ //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype._initSourceImage = function(onReady) { +ARjs.Source.prototype._initSourceImage = function(onReady) { // TODO make it static var domElement = document.createElement('img') domElement.src = this.parameters.sourceUrl @@ -1463,7 +1490,7 @@ THREEx.ArToolkitSource.prototype._initSourceImage = function(onReady) { //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype._initSourceVideo = function(onReady) { +ARjs.Source.prototype._initSourceVideo = function(onReady) { // TODO make it static var domElement = document.createElement('video'); domElement.src = this.parameters.sourceUrl @@ -1500,12 +1527,12 @@ THREEx.ArToolkitSource.prototype._initSourceVideo = function(onReady) { // handle webcam source //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype._initSourceWebcam = function(onReady, onError) { +ARjs.Source.prototype._initSourceWebcam = function(onReady, onError) { var _this = this -debugger + // init default value onError = onError || function(error){ - alert('Cant init webcam due to '+error.message) + alert('Webcam Error\nName: '+error.name + '\nMessage: '+error.message) } var domElement = document.createElement('video'); @@ -1515,13 +1542,18 @@ debugger domElement.style.width = this.parameters.displayWidth+'px' domElement.style.height = this.parameters.displayHeight+'px' + // check API is available if (navigator.mediaDevices === undefined || navigator.mediaDevices.enumerateDevices === undefined || navigator.mediaDevices.getUserMedia === undefined ){ - onError("WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser") + onError({ + name: '', + message: 'WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser' + }) return } + // get available devices navigator.mediaDevices.enumerateDevices().then(function(devices) { var userMediaConstraints = { audio: false, @@ -1539,6 +1571,7 @@ debugger } } } + // get a device which satisfy the constraints navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream) { // set the .src of the domElement domElement.srcObject = stream; @@ -1547,6 +1580,7 @@ debugger domElement.play(); }) // domElement.play(); + // TODO listen to loadedmetadata instead // wait until the video stream is ready var interval = setInterval(function() { @@ -1556,7 +1590,8 @@ debugger }, 1000/50); }).catch(function(error) { onError({ - message: "Can't access user media :()" + name: error.name, + message: error.message }); }); }).catch(function(error) { @@ -1571,7 +1606,7 @@ debugger ////////////////////////////////////////////////////////////////////////////// // Handle Mobile Torch ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.hasMobileTorch = function(){ +ARjs.Source.prototype.hasMobileTorch = function(){ var stream = arToolkitSource.domElement.srcObject if( stream instanceof MediaStream === false ) return false @@ -1593,7 +1628,7 @@ THREEx.ArToolkitSource.prototype.hasMobileTorch = function(){ * toggle the flash/torch of the mobile fun if applicable. * Great post about it https://www.oberhofer.co/mediastreamtrack-and-its-capabilities/ */ -THREEx.ArToolkitSource.prototype.toggleMobileTorch = function(){ +ARjs.Source.prototype.toggleMobileTorch = function(){ // sanity check console.assert(this.hasMobileTorch() === true) @@ -1629,7 +1664,7 @@ THREEx.ArToolkitSource.prototype.toggleMobileTorch = function(){ // handle resize //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.onResizeElement = function(mirrorDomElements){ +ARjs.Source.prototype.onResizeElement = function(mirrorDomElements){ var _this = this var screenWidth = window.innerWidth var screenHeight = window.innerHeight @@ -1687,7 +1722,7 @@ THREEx.ArToolkitSource.prototype.onResizeElement = function(mirrorDomElements){ }) } -THREEx.ArToolkitSource.prototype.copyElementSizeTo = function(otherElement){ +ARjs.Source.prototype.copyElementSizeTo = function(otherElement){ otherElement.style.width = this.domElement.style.width otherElement.style.height = this.domElement.style.height otherElement.style.marginLeft = this.domElement.style.marginLeft @@ -1698,7 +1733,7 @@ THREEx.ArToolkitSource.prototype.copyElementSizeTo = function(otherElement){ // Code Separator ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.copySizeTo = function(){ +ARjs.Source.prototype.copySizeTo = function(){ console.warn('obsolete function arToolkitSource.copySizeTo. Use arToolkitSource.copyElementSizeTo' ) this.copyElementSizeTo.apply(this, arguments) } @@ -1707,14 +1742,15 @@ THREEx.ArToolkitSource.prototype.copySizeTo = function(){ // Code Separator ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.onResize = function(arToolkitContext, renderer, camera){ - var trackingBackend = arToolkitContext.parameters.trackingBackend - +ARjs.Source.prototype.onResize = function(arToolkitContext, renderer, camera){ if( arguments.length !== 3 ){ console.warn('obsolete function arToolkitSource.onResize. Use arToolkitSource.onResizeElement' ) return this.onResizeElement.apply(this, arguments) } + var trackingBackend = arToolkitContext.parameters.trackingBackend + + // RESIZE DOMELEMENT if( trackingBackend === 'artoolkit' ){ @@ -2657,6 +2693,435 @@ THREEx.ArMultiMarkerUtils.createDefaultMarkersControlsParameters = function(trac }else console.assert(false) return markersControlsParameters } +// @namespace +var ARjs = ARjs || {} + +// TODO this is a controls... should i give the object3d here ? +// not according to 'no three.js dependancy' + +/** + * Create an anchor in the real world + * + * @param {ARjs.Session} arSession - the session on which we create the anchor + * @param {Object} markerParameters - parameter of this anchor + */ +ARjs.Anchor = function(arSession, markerParameters){ + var _this = this + var arContext = arSession.arContext + var scene = arSession.scene + var camera = arSession.camera + + this.parameters = markerParameters + + // log to debug + console.log('ARjs.Anchor -', 'changeMatrixMode:', this.parameters.changeMatrixMode, '/ markersAreaEnabled:', markerParameters.markersAreaEnabled) + + + var markerRoot = new THREE.Group + scene.add(markerRoot) + + // set controlledObject depending on changeMatrixMode + if( markerParameters.changeMatrixMode === 'modelViewMatrix' ){ + var controlledObject = markerRoot + }else if( markerParameters.changeMatrixMode === 'cameraTransformMatrix' ){ + var controlledObject = camera + }else console.assert(false) + + if( markerParameters.markersAreaEnabled === false ){ + var markerControls = new THREEx.ArMarkerControls(arContext, controlledObject, markerParameters) + }else{ + // sanity check - MUST be a trackingBackend with markers + console.assert( arContext.parameters.trackingBackend === 'artoolkit' || arContext.parameters.trackingBackend === 'aruco' ) + // for multi marker + if( localStorage.getItem('ARjsMultiMarkerFile') === null ){ + THREEx.ArMultiMarkerUtils.storeDefaultMultiMarkerFile(arContext.parameters.trackingBackend) + } + + // get multiMarkerFile from localStorage + console.assert( localStorage.getItem('ARjsMultiMarkerFile') !== null ) + var multiMarkerFile = localStorage.getItem('ARjsMultiMarkerFile') + + // build a multiMarkerControls + var multiMarkerControls = THREEx.ArMultiMarkerControls.fromJSON(arContext, scene, controlledObject, multiMarkerFile) + + // honor markerParameters.changeMatrixMode + multiMarkerControls.parameters.changeMatrixMode = markerParameters.changeMatrixMode + + // create ArMarkerHelper - useful to debug + var markerHelpers = [] + multiMarkerControls.subMarkersControls.forEach(function(subMarkerControls){ + // add an helper to visuable each sub-marker + var markerHelper = new THREEx.ArMarkerHelper(subMarkerControls) + markerHelper.object3d.visible = false + subMarkerControls.object3d.add( markerHelper.object3d ) + // add it to markerHelpers + markerHelpers.push(markerHelper) + }) + // define API specific to markersArea + this.markersArea = {} + this.markersArea.setSubMarkersVisibility = function(visible){ + markerHelpers.forEach(function(markerHelper){ + markerHelper.object3d.visible = visible + }) + } + } + + this.object3d = new THREE.Group() + + ////////////////////////////////////////////////////////////////////////////// + // THREEx.ArSmoothedControls + ////////////////////////////////////////////////////////////////////////////// + + var shouldBeSmoothed = true + if( arContext.parameters.trackingBackend === 'tango' ) shouldBeSmoothed = false + + if( shouldBeSmoothed === true ){ + // build a smoothedControls + var smoothedRoot = new THREE.Group() + scene.add(smoothedRoot) + var smoothedControls = new THREEx.ArSmoothedControls(smoothedRoot) + smoothedRoot.add(this.object3d) + }else{ + markerRoot.add(this.object3d) + } + + + ////////////////////////////////////////////////////////////////////////////// + // Code Separator + ////////////////////////////////////////////////////////////////////////////// + this.update = function(){ + // update scene.visible if the marker is seen + if( markerParameters.changeMatrixMode === 'cameraTransformMatrix' ){ + _this.object3d.visible = controlledObject.visible + } + + if( smoothedControls !== undefined ){ + // update smoothedControls parameters depending on how many markers are visible in multiMarkerControls + if( multiMarkerControls !== undefined ){ + multiMarkerControls.updateSmoothedControls(smoothedControls) + } + + // update smoothedControls + smoothedControls.update(markerRoot) + } + } +} + + +/** + * Apply ARjs.Session.HitTestResult to the controlled object3d + * + * @param {ARjs.HitTester.Result} hitTestResult - the result to apply + */ +ARjs.Anchor.prototype.applyHitTestResult = function(hitTestResult){ + + + this.object3d.position.copy(hitTestResult.position) + this.object3d.quaternion.copy(hitTestResult.quaternion) + this.object3d.scale.copy(hitTestResult.scale) + + this.object3d.updateMatrix() +} +// @namespace +var ARjs = ARjs || {} + +/** + * Create an anchor in the real world + * + * @param {ARjs.Session} arSession - the session on which we create the anchor + * @param {Object} markerParameters - parameter of this anchor + */ +ARjs.HitTester = function(arSession){ + var _this = this + this.arSession = arSession + + var arContext = this.arSession.arContext + var trackingBackend = arContext.parameters.trackingBackend + + if( trackingBackend === 'tango' ){ + // Do nothing... + }else{ + arContext.addEventListener('initialized', function(event){ + _this._arClickability = new THREEx.ARClickability(arSession.arSource.domElement) + _this._pickingScene = new THREE.Scene + + var geometry = new THREE.PlaneGeometry(20,20,19,19).rotateX(-Math.PI/2) + var geometry = new THREE.PlaneGeometry(20,20).rotateX(-Math.PI/2) + var material = new THREE.MeshBasicMaterial({ + opacity: 0.5, + transparent: true, + wireframe: true + }) + material.visible = false + _this._pickingPlane = new THREE.Mesh(geometry, material) + _this._pickingScene.add(_this._pickingPlane) + }) + } + + +} + + +ARjs.HitTester.prototype.update = function (camera, object3d) { + var arContext = this.arSession.arContext + var trackingBackend = arContext.parameters.trackingBackend + + if( trackingBackend === 'tango' ){ + // Do nothing... + }else{ + if( arContext.initialized === false ) return + + this._arClickability.onResize() + + // // set cameraPicking position + var cameraPicking = this._arClickability._cameraPicking + // camera.updateMatrixWorld() + // cameraPicking.matrix.copy(object3d.matrixWorld) + // cameraPicking.matrix.decompose(cameraPicking.position, cameraPicking.quaternion, cameraPicking.scale) + + + // set pickingPlane position + var pickingPlane = this._pickingPlane + object3d.parent.updateMatrixWorld() + pickingPlane.matrix.copy(object3d.parent.matrixWorld) + pickingPlane.matrix.decompose(pickingPlane.position, pickingPlane.quaternion, pickingPlane.scale) + +// var position = pickingPlane.position +// console.log('this._pickingPlane position', position.x.toFixed(2), position.y.toFixed(2), position.z.toFixed(2)) +// var position = cameraPicking.position +// console.log('this.cameraPicking position', position.x.toFixed(2), position.y.toFixed(2), position.z.toFixed(2)) + + } +} + +/** + * Test the real world for intersections. + * + * @param {Number} mouseX - position X of the hit [-1, +1] + * @param {Number} mouseY - position Y of the hit [-1, +1] + * @return {[ARjs.HitTester.Result]} - array of result + */ +ARjs.HitTester.prototype.testDomEvent = function(domEvent){ + var trackingBackend = this.arSession.arContext.parameters.trackingBackend + var arSource = this.arSession.arSource + + if( trackingBackend === 'tango' ){ + var mouseX = domEvent.pageX / window.innerWidth + var mouseY = domEvent.pageY / window.innerHeight + }else{ + var mouseX = domEvent.layerX / parseInt(arSource.domElement.style.width) + var mouseY = domEvent.layerY / parseInt(arSource.domElement.style.height) + } + + return this.test(mouseX, mouseY) +} + +/** + * Test the real world for intersections. + * + * @param {Number} mouseX - position X of the hit [0, +1] + * @param {Number} mouseY - position Y of the hit [0, +1] + * @return {[ARjs.HitTester.Result]} - array of result + */ +ARjs.HitTester.prototype.test = function(mouseX, mouseY){ + var arContext = this.arSession.arContext + var trackingBackend = arContext.parameters.trackingBackend + var hitTestResults = [] + + if( trackingBackend === 'tango' ){ + var result = THREEx.ARClickability.tangoPickingPointCloud(arContext, mouseX, mouseY) + if( result !== null ){ + var scale = new THREE.Vector3(1,1,1).multiplyScalar(0.1) + var hitTestResult = new ARjs.HitTester.Result(result.position, result.quaternion, scale) + hitTestResults.push(hitTestResult) + } + }else{ + + mouseX = (mouseX-0.5)*2 + mouseY =-(mouseY-0.5)*2 + + this._pickingScene.updateMatrixWorld(true) + // compute intersections between mouseVector3 and pickingPlane + var raycaster = new THREE.Raycaster(); + var mouseVector3 = new THREE.Vector3(mouseX, mouseY, 1); + raycaster.setFromCamera( mouseVector3, this._arClickability._cameraPicking ); + var intersects = raycaster.intersectObjects( [this._pickingPlane] ) + + // if no intersection occurs, return now + if( intersects.length > 0 ){ + // console.log('mouseX', mouseX, 'mouseY', mouseY) + // console.log(intersects[0].point) + // set new demoRoot position + var newPosition = this._pickingPlane.worldToLocal( intersects[0].point.clone() ) + // console.log(newPosition) + + var scale = new THREE.Vector3(1,1,1).multiplyScalar(1) + var hitTestResult = new ARjs.HitTester.Result(newPosition, new THREE.Quaternion, scale) + hitTestResults.push(hitTestResult) + } + } + + // TODO use clickability + return hitTestResults +} + + +////////////////////////////////////////////////////////////////////////////// +// ARjs.HitTester.Result +////////////////////////////////////////////////////////////////////////////// +/** + * Contains the result of ARjs.HitTester.test() + * + * @param {THREE.Vector3} position - position to use + * @param {THREE.Quaternion} quaternion - quaternion to use + * @param {THREE.Vector3} scale - scale + */ +ARjs.HitTester.Result = function(position, quaternion, scale){ + this.position = position + this.quaternion = quaternion + this.scale = scale +} +var ARjs = ARjs || {} + +/** + * define a ARjs.Session + * + * @param {Object} parameters - parameters for this session + */ +ARjs.Session = function(parameters){ + var _this = this + + this.renderer = parameters.renderer + this.camera = parameters.camera + this.scene = parameters.scene + + // log the version + console.log('AR.js', THREEx.ArToolkitContext.REVISION, '- trackingBackend:', parameters.contextParameters.trackingBackend) + + ////////////////////////////////////////////////////////////////////////////// + // init arSource + ////////////////////////////////////////////////////////////////////////////// + var arSource = _this.arSource = new THREEx.ArToolkitSource(parameters.sourceParameters) + + arSource.init(function onReady(){ + arSource.onResize(arContext, _this.renderer, _this.camera) + }) + + // handle resize + window.addEventListener('resize', function(){ + arSource.onResize(arContext, _this.renderer, _this.camera) + }) + + ////////////////////////////////////////////////////////////////////////////// + // init arContext + ////////////////////////////////////////////////////////////////////////////// + + // create atToolkitContext + var arContext = _this.arContext = new THREEx.ArToolkitContext(parameters.contextParameters) + + // initialize it + _this.arContext.init() + + arContext.addEventListener('initialized', function(event){ + arSource.onResize(arContext, _this.renderer, _this.camera) + }) + + ////////////////////////////////////////////////////////////////////////////// + // update function + ////////////////////////////////////////////////////////////////////////////// + // update artoolkit on every frame + this.update = function(){ + if( arSource.ready === false ) return + + arContext.update( arSource.domElement ) + } +} + +ARjs.Session.prototype.onResize = function () { + this.arSource.onResize(this.arContext, this.renderer, this.camera) +}; +// @namespace +var ARjs = ARjs || {} + +ARjs.TangoPointCloud = function(arSession){ + var _this = this + var arContext = arSession.arContext + this.object3d = new THREE.Group + +console.warn('Work only on cameraTransformMatrix - fix me - useless limitation') + + arContext.addEventListener('initialized', function(event){ + var vrPointCloud = arContext._tangoContext.vrPointCloud + var geometry = vrPointCloud.getBufferGeometry() + var material = new THREE.PointsMaterial({ + size: 0.01, + // colorWrite: false, // good for occlusion + depthWrite: false, + }) + var pointsObject = new THREE.Points(geometry, material) + // Points are changing all the time so calculating the frustum culling volume is not very convenient. + pointsObject.frustumCulled = false; + pointsObject.renderDepth = 0; + + _this.object3d.add(pointsObject) + }) +} +// @namespace +var ARjs = ARjs || {} + +ARjs.TangoVideoMesh = function(arSession){ + var arContext = arSession.arContext + var renderer = arSession.renderer + + var videoMesh = null + var vrDisplay = null + + // Create the see through camera scene and camera + var sceneOrtho = new THREE.Scene() + var cameraOrtho = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 100 ) +this._sceneOrtho = sceneOrtho +this._cameraOrtho = cameraOrtho + + // tango only - init cameraMesh + arContext.addEventListener('initialized', function(event){ + // sanity check + console.assert( arContext.parameters.trackingBackend === 'tango' ) + // variable declaration + vrDisplay = arContext._tangoContext.vrDisplay + console.assert(vrDisplay, 'vrDisplay MUST be defined') + // if vrDisplay isnt for tango, do nothing. It may be another vrDisplay (e.g. webvr emulator in chrome) + if( vrDisplay.displayName !== "Tango VR Device" ) return + // init videoPlane + videoMesh = THREE.WebAR.createVRSeeThroughCameraMesh(vrDisplay) + sceneOrtho.add(videoMesh) + }) + + ////////////////////////////////////////////////////////////////////////////// + // Code Separator + ////////////////////////////////////////////////////////////////////////////// + + this.update = function(){ + // sanity check + console.assert( arContext.parameters.trackingBackend === 'tango' ) + // if not yet initialized, return now + if( videoMesh === null ) return + // Make sure that the camera is correctly displayed depending on the device and camera orientations. + THREE.WebAR.updateCameraMeshOrientation(vrDisplay, videoMesh) + } + + ////////////////////////////////////////////////////////////////////////////// + // Code Separator + ////////////////////////////////////////////////////////////////////////////// + + this.render = function(){ + // sanity check + console.assert( arContext.parameters.trackingBackend === 'tango' ) + // render sceneOrtho + renderer.render( sceneOrtho, cameraOrtho ) + // Render the perspective scene + renderer.clearDepth() + } +} ////////////////////////////////////////////////////////////////////////////// // Code Separator ////////////////////////////////////////////////////////////////////////////// diff --git a/aframe/build/aframe-ar.min.js b/aframe/build/aframe-ar.min.js index 1661b3f..2654227 100644 --- a/aframe/build/aframe-ar.min.js +++ b/aframe/build/aframe-ar.min.js @@ -1,7 +1,7 @@ -var THREEx=THREEx||{};THREEx.ArBaseControls=function(object3d){this.id=THREEx.ArBaseControls.id++;this.object3d=object3d;this.object3d.matrixAutoUpdate=false;this.object3d.visible=false};THREEx.ArBaseControls.id=0;Object.assign(THREEx.ArBaseControls.prototype,THREE.EventDispatcher.prototype);THREEx.ArBaseControls.prototype.update=function(){console.assert(false,"you need to implement your own update")};THREEx.ArBaseControls.prototype.name=function(){console.assert(false,"you need to implement your own .name()");return"Not yet implemented - name()"};var THREEx=THREEx||{};THREEx.ARClickability=function(sourceElement){this._sourceElement=sourceElement;var fullWidth=parseInt(sourceElement.style.width);var fullHeight=parseInt(sourceElement.style.height);this._cameraPicking=new THREE.PerspectiveCamera(42,fullWidth/fullHeight,.1,100);console.warn("THREEx.ARClickability works only in modelViewMatrix")};THREEx.ARClickability.prototype.onResize=function(){var sourceElement=this._sourceElement;var cameraPicking=this._cameraPicking;var fullWidth=parseInt(sourceElement.style.width);var fullHeight=parseInt(sourceElement.style.height);cameraPicking.aspect=fullWidth/fullHeight;cameraPicking.updateProjectionMatrix()};THREEx.ARClickability.prototype.computeIntersects=function(domEvent,objects){var sourceElement=this._sourceElement;var cameraPicking=this._cameraPicking;var eventCoords=new THREE.Vector3;eventCoords.x=domEvent.layerX/parseInt(sourceElement.style.width)*2-1;eventCoords.y=-(domEvent.layerY/parseInt(sourceElement.style.height))*2+1;var raycaster=new THREE.Raycaster;raycaster.setFromCamera(eventCoords,cameraPicking);var intersects=raycaster.intersectObjects(objects);return intersects};THREEx.ARClickability.prototype.update=function(){};THREEx.ARClickability.tangoPickingPointCloud=function(artoolkitContext,mouseX,mouseY){var vrDisplay=artoolkitContext._tangoContext.vrDisplay;if(vrDisplay===null)return null;var pointAndPlane=vrDisplay.getPickingPointAndPlaneInPointCloud(mouseX,mouseY);if(pointAndPlane==null){console.warn("Could not retrieve the correct point and plane.");return null}var boundingSphereRadius=.01;var object3d=new THREE.Object3D;THREE.WebAR.positionAndRotateObject3DWithPickingPointAndPlaneInPointCloud(pointAndPlane,object3d,boundingSphereRadius);object3d.rotateZ(-Math.PI/2);var result={};result.position=object3d.position;result.quaternion=object3d.quaternion;return result};var THREEx=THREEx||{};THREEx.ArMarkerCloak=function(videoTexture){var updateInShaderEnabled=true;var geometry=new THREE.PlaneGeometry(1.3+.25,1.85+.25,1,8).translate(0,-.3,0);var material=new THREE.ShaderMaterial({vertexShader:THREEx.ArMarkerCloak.vertexShader,fragmentShader:THREEx.ArMarkerCloak.fragmentShader,transparent:true,uniforms:{texture:{value:videoTexture},opacity:{value:.5}},defines:{updateInShaderEnabled:updateInShaderEnabled?1:0}});var cloakMesh=new THREE.Mesh(geometry,material);cloakMesh.rotation.x=-Math.PI/2;this.object3d=cloakMesh;var xMin=-.65;var xMax=.65;var yMin=.65+.1;var yMax=.95+.1;var originalsFaceVertexUvs=[[]];for(var faceIndex=0;faceIndex=this.parameters.minVisibleDelay){object3d.visible=true;snapDirectlyToTarget()}}if(wasVisible===true&&targetObject3d.visible===false){var unvisibleFor=present-this._unvisibleStartedAt;if(unvisibleFor>=this.parameters.minUnvisibleDelay){object3d.visible=false}}if(this._lastLerpStepAt===null){applyOneSlerpStep();this._lastLerpStepAt=present}else{var nStepsToDo=Math.floor((present-this._lastLerpStepAt)/this.parameters.lerpStepDelay);for(var i=0;iwebvr.info for more info.")}else{alert("Your browser does not support WebVR. See webvr.info for assistance.")}this._tangoContext={vrDisplay:null,vrPointCloud:null,frameData:new VRFrameData};navigator.getVRDisplays().then(function(vrDisplays){if(vrDisplays.length===0)alert("no vrDisplays available");var vrDisplay=_this._tangoContext.vrDisplay=vrDisplays[0];console.log("vrDisplays.displayName :",vrDisplay.displayName);if(vrDisplay.displayName==="Tango VR Device"){_this._tangoContext.vrPointCloud=new THREE.WebAR.VRPointCloud(vrDisplay,true)}onCompleted()})};THREEx.ArToolkitContext.prototype._updateTango=function(srcElement){var _this=this;var arMarkersControls=this._arMarkersControls;var tangoContext=this._tangoContext;var vrDisplay=this._tangoContext.vrDisplay;if(vrDisplay===null)return;if(vrDisplay.displayName==="Tango VR Device"){var showPointCloud=true;var pointsToSkip=0;_this._tangoContext.vrPointCloud.update(showPointCloud,pointsToSkip,true)}if(this._arMarkersControls.length===0)return;var foundControls=this._arMarkersControls[0];var frameData=this._tangoContext.frameData;vrDisplay.getFrameData(frameData);if(frameData.pose.position===null)return;if(frameData.pose.orientation===null)return;var position=(new THREE.Vector3).fromArray(frameData.pose.position);var quaternion=(new THREE.Quaternion).fromArray(frameData.pose.orientation);var scale=new THREE.Vector3(1,1,1);var cameraTransformMatrix=(new THREE.Matrix4).compose(position,quaternion,scale);var modelViewMatrix=new THREE.Matrix4;modelViewMatrix.getInverse(cameraTransformMatrix);foundControls.updateWithModelViewMatrix(modelViewMatrix)};var ARjs=ARjs||{};var THREEx=THREEx||{};ARjs.Profile=THREEx.ArToolkitProfile=function(){this.reset();this.performance("default")};ARjs.Profile.prototype._guessPerformanceLabel=function(){var isMobile=navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i)?true:false;if(isMobile===true){return"phone-normal"}return"desktop-normal"};ARjs.Profile.prototype.reset=function(){this.sourceParameters={sourceType:"webcam"};this.contextParameters={cameraParametersUrl:THREEx.ArToolkitContext.baseURL+"../data/data/camera_para.dat",detectionMode:"mono"};this.defaultMarkerParameters={type:"pattern",patternUrl:THREEx.ArToolkitContext.baseURL+"../data/data/patt.hiro",changeMatrixMode:"modelViewMatrix"};return this};ARjs.Profile.prototype.performance=function(label){if(label==="default"){label=this._guessPerformanceLabel()}if(label==="desktop-fast"){this.contextParameters.canvasWidth=640*3;this.contextParameters.canvasHeight=480*3;this.contextParameters.maxDetectionRate=30}else if(label==="desktop-normal"){this.contextParameters.canvasWidth=640;this.contextParameters.canvasHeight=480;this.contextParameters.maxDetectionRate=60}else if(label==="phone-normal"){this.contextParameters.canvasWidth=80*4;this.contextParameters.canvasHeight=60*4;this.contextParameters.maxDetectionRate=30}else if(label==="phone-slow"){this.contextParameters.canvasWidth=80*3;this.contextParameters.canvasHeight=60*3;this.contextParameters.maxDetectionRate=30}else{console.assert(false,"unknonwn label "+label)}return this};ARjs.Profile.prototype.defaultMarker=function(trackingBackend){trackingBackend=trackingBackend||this.contextParameters.trackingBackend;if(trackingBackend==="artoolkit"){this.contextParameters.detectionMode="mono";this.defaultMarkerParameters.type="pattern";this.defaultMarkerParameters.patternUrl=THREEx.ArToolkitContext.baseURL+"../data/data/patt.hiro"}else if(trackingBackend==="aruco"){this.contextParameters.detectionMode="mono";this.defaultMarkerParameters.type="barcode";this.defaultMarkerParameters.barcodeValue=1001}else if(trackingBackend==="tango"){this.defaultMarkerParameters.type="barcode";this.defaultMarkerParameters.barcodeValue=1001}else console.assert(false);return this};ARjs.Profile.prototype.sourceWebcam=function(){this.sourceParameters.sourceType="webcam";delete this.sourceParameters.sourceUrl;return this};ARjs.Profile.prototype.sourceVideo=function(url){this.sourceParameters.sourceType="video";this.sourceParameters.sourceUrl=url;return this};ARjs.Profile.prototype.sourceImage=function(url){this.sourceParameters.sourceType="image";this.sourceParameters.sourceUrl=url;return this};ARjs.Profile.prototype.trackingBackend=function(trackingBackend){console.warn("stop profile.trackingBackend() obsolete function. use .trackingMethod instead");this.contextParameters.trackingBackend=trackingBackend;return this};ARjs.Profile.prototype.changeMatrixMode=function(changeMatrixMode){this.defaultMarkerParameters.changeMatrixMode=changeMatrixMode;return this};ARjs.Profile.prototype.trackingMethod=function(trackingMethod){var data=ARjs.Utils.parseTrackingMethod(trackingMethod);this.defaultMarkerParameters.markersAreaEnabled=data.markersAreaEnabled;this.contextParameters.trackingBackend=data.trackingBackend;return this};ARjs.Profile.prototype.checkIfValid=function(){if(this.contextParameters.trackingBackend==="tango"){this.sourceImage(THREEx.ArToolkitContext.baseURL+"../data/images/img.jpg")}return this};var THREEx=THREEx||{};THREEx.ArToolkitSource=function(parameters){this.parameters={sourceType:parameters.sourceType!==undefined?parameters.sourceType:"webcam",sourceUrl:parameters.sourceUrl!==undefined?parameters.sourceUrl:null,sourceWidth:parameters.sourceWidth!==undefined?parameters.sourceWidth:640,sourceHeight:parameters.sourceHeight!==undefined?parameters.sourceHeight:480,displayWidth:parameters.displayWidth!==undefined?parameters.displayWidth:640,displayHeight:parameters.displayHeight!==undefined?parameters.displayHeight:480};this.ready=false;this.domElement=null};THREEx.ArToolkitSource.prototype.init=function(onReady){var _this=this;if(this.parameters.sourceType==="image"){var domElement=this._initSourceImage(onSourceReady)}else if(this.parameters.sourceType==="video"){var domElement=this._initSourceVideo(onSourceReady)}else if(this.parameters.sourceType==="webcam"){var domElement=this._initSourceWebcam(onSourceReady)}else{console.assert(false)}this.domElement=domElement;this.domElement.style.position="absolute";this.domElement.style.top="0px";this.domElement.style.left="0px";this.domElement.style.zIndex="-2";return this;function onSourceReady(){document.body.appendChild(_this.domElement);_this.ready=true;onReady&&onReady()}};THREEx.ArToolkitSource.prototype._initSourceImage=function(onReady){var domElement=document.createElement("img");domElement.src=this.parameters.sourceUrl;domElement.width=this.parameters.sourceWidth;domElement.height=this.parameters.sourceHeight;domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";var interval=setInterval(function(){if(!domElement.naturalWidth)return;onReady();clearInterval(interval)},1e3/50);return domElement};THREEx.ArToolkitSource.prototype._initSourceVideo=function(onReady){var domElement=document.createElement("video"); -domElement.src=this.parameters.sourceUrl;domElement.style.objectFit="initial";domElement.autoplay=true;domElement.webkitPlaysinline=true;domElement.controls=false;domElement.loop=true;domElement.muted=true;document.body.addEventListener("click",function onClick(){document.body.removeEventListener("click",onClick);domElement.play()});domElement.width=this.parameters.sourceWidth;domElement.height=this.parameters.sourceHeight;domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";var interval=setInterval(function(){if(!domElement.videoWidth)return;onReady();clearInterval(interval)},1e3/50);return domElement};THREEx.ArToolkitSource.prototype._initSourceWebcam=function(onReady){var _this=this;var domElement=document.createElement("video");domElement.setAttribute("autoplay","");domElement.setAttribute("muted","");domElement.setAttribute("playsinline","");domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";if(navigator.mediaDevices===undefined||navigator.mediaDevices.enumerateDevices===undefined||navigator.mediaDevices.getUserMedia===undefined){alert("WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser")}navigator.mediaDevices.enumerateDevices().then(function(devices){var userMediaConstraints={audio:false,video:{facingMode:"environment",width:{ideal:_this.parameters.sourceWidth},height:{ideal:_this.parameters.sourceHeight}}};navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream){domElement.srcObject=stream;document.body.addEventListener("click",function(){domElement.play()});var interval=setInterval(function(){if(!domElement.videoWidth)return;onReady();clearInterval(interval)},1e3/50)}).catch(function(error){console.log("Can't access user media",error);alert("Can't access user media :()")})}).catch(function(err){console.log(err.name+": "+err.message)});return domElement};THREEx.ArToolkitSource.prototype.hasMobileTorch=function(){var stream=arToolkitSource.domElement.srcObject;if(stream instanceof MediaStream===false)return false;if(this._currentTorchStatus===undefined){this._currentTorchStatus=false}var videoTrack=stream.getVideoTracks()[0];if(videoTrack.getCapabilities===undefined)return false;var capabilities=videoTrack.getCapabilities();return capabilities.torch?true:false};THREEx.ArToolkitSource.prototype.toggleMobileTorch=function(){console.assert(this.hasMobileTorch()===true);var stream=arToolkitSource.domElement.srcObject;if(stream instanceof MediaStream===false){alert("enabling mobile torch is available only on webcam");return}if(this._currentTorchStatus===undefined){this._currentTorchStatus=false}var videoTrack=stream.getVideoTracks()[0];var capabilities=videoTrack.getCapabilities();if(!capabilities.torch){alert("no mobile torch is available on your camera");return}this._currentTorchStatus=this._currentTorchStatus===false?true:false;videoTrack.applyConstraints({advanced:[{torch:this._currentTorchStatus}]}).catch(function(error){console.log(error)})};THREEx.ArToolkitSource.prototype.onResizeElement=function(mirrorDomElements){var _this=this;var screenWidth=window.innerWidth;var screenHeight=window.innerHeight;if(this.domElement.nodeName==="IMG"){var sourceWidth=this.domElement.naturalWidth;var sourceHeight=this.domElement.naturalHeight}else if(this.domElement.nodeName==="VIDEO"){var sourceWidth=this.domElement.videoWidth;var sourceHeight=this.domElement.videoHeight}else{console.assert(false)}var sourceAspect=sourceWidth/sourceHeight;var screenAspect=screenWidth/screenHeight;if(screenAspect3)console.assert("wrong api for",THREEx.ArMultiMarkerControls);this.parameters={subMarkersControls:parameters.subMarkersControls,subMarkerPoses:parameters.subMarkerPoses,changeMatrixMode:parameters.changeMatrixMode!==undefined?parameters.changeMatrixMode:"modelViewMatrix"};this.object3d.visible=false;this.subMarkersControls=this.parameters.subMarkersControls;this.subMarkerPoses=this.parameters.subMarkerPoses;arToolkitContext.addEventListener("sourceProcessed",function(){_this._onSourceProcessed()})};THREEx.ArMultiMarkerControls.prototype=Object.create(THREEx.ArBaseControls.prototype);THREEx.ArMultiMarkerControls.prototype.constructor=THREEx.ArMultiMarkerControls;THREEx.ArMultiMarkerControls.prototype._onSourceProcessed=function(){var _this=this;var stats={count:0,position:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)},quaternion:{sum:new THREE.Quaternion(0,0,0,0),average:new THREE.Quaternion(0,0,0,0)},scale:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)}};var firstQuaternion=_this.parameters.subMarkersControls[0].object3d.quaternion;this.parameters.subMarkersControls.forEach(function(markerControls,markerIndex){var markerObject3d=markerControls.object3d;if(markerObject3d.visible===false)return;var matrix=markerObject3d.matrix.clone();var markerPose=_this.parameters.subMarkerPoses[markerIndex];matrix.multiply((new THREE.Matrix4).getInverse(markerPose));var position=new THREE.Vector3;var quaternion=new THREE.Quaternion;var scale=new THREE.Vector3;matrix.decompose(position,quaternion,scale);stats.count++;THREEx.ArMultiMarkerControls.averageVector3(stats.position.sum,position,stats.count,stats.position.average);THREEx.ArMultiMarkerControls.averageQuaternion(stats.quaternion.sum,quaternion,firstQuaternion,stats.count,stats.quaternion.average);THREEx.ArMultiMarkerControls.averageVector3(stats.scale.sum,scale,stats.count,stats.scale.average)});if(stats.count>0){_this.object3d.visible=true}else{_this.object3d.visible=false}if(stats.count>0){var modelViewMatrix=new THREE.Matrix4;modelViewMatrix.compose(stats.position.average,stats.quaternion.average,stats.scale.average);if(this.parameters.changeMatrixMode==="modelViewMatrix"){_this.object3d.matrix.copy(modelViewMatrix)}else if(this.parameters.changeMatrixMode==="cameraTransformMatrix"){_this.object3d.matrix.getInverse(modelViewMatrix)}else{console.assert(false)}_this.object3d.matrix.decompose(_this.object3d.position,_this.object3d.quaternion,_this.object3d.scale)}};THREEx.ArMultiMarkerControls.averageQuaternion=function(quaternionSum,newQuaternion,firstQuaternion,count,quaternionAverage){quaternionAverage=quaternionAverage||new THREE.Quaternion;console.assert(firstQuaternion instanceof THREE.Quaternion===true);if(newQuaternion.dot(firstQuaternion)>0){newQuaternion=new THREE.Quaternion(-newQuaternion.x,-newQuaternion.y,-newQuaternion.z,-newQuaternion.w)}quaternionSum.x+=newQuaternion.x;quaternionSum.y+=newQuaternion.y;quaternionSum.z+=newQuaternion.z;quaternionSum.w+=newQuaternion.w;quaternionAverage.x=quaternionSum.x/count;quaternionAverage.y=quaternionSum.y/count;quaternionAverage.z=quaternionSum.z/count;quaternionAverage.w=quaternionSum.w/count;quaternionAverage.normalize();return quaternionAverage};THREEx.ArMultiMarkerControls.averageVector3=function(vector3Sum,vector3,count,vector3Average){vector3Average=vector3Average||new THREE.Vector3;vector3Sum.x+=vector3.x;vector3Sum.y+=vector3.y;vector3Sum.z+=vector3.z;vector3Average.x=vector3Sum.x/count;vector3Average.y=vector3Sum.y/count;vector3Average.z=vector3Sum.z/count;return vector3Average};THREEx.ArMultiMarkerControls.computeCenter=function(jsonData){var multiMarkerFile=JSON.parse(jsonData);var stats={count:0,position:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)},quaternion:{sum:new THREE.Quaternion(0,0,0,0),average:new THREE.Quaternion(0,0,0,0)},scale:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)}};var firstQuaternion=new THREE.Quaternion;multiMarkerFile.subMarkersControls.forEach(function(item){var poseMatrix=(new THREE.Matrix4).fromArray(item.poseMatrix);var position=new THREE.Vector3;var quaternion=new THREE.Quaternion;var scale=new THREE.Vector3;poseMatrix.decompose(position,quaternion,scale);stats.count++;THREEx.ArMultiMarkerControls.averageVector3(stats.position.sum,position,stats.count,stats.position.average);THREEx.ArMultiMarkerControls.averageQuaternion(stats.quaternion.sum,quaternion,firstQuaternion,stats.count,stats.quaternion.average);THREEx.ArMultiMarkerControls.averageVector3(stats.scale.sum,scale,stats.count,stats.scale.average)});var averageMatrix=new THREE.Matrix4;averageMatrix.compose(stats.position.average,stats.quaternion.average,stats.scale.average);return averageMatrix};THREEx.ArMultiMarkerControls.computeBoundingBox=function(jsonData){var multiMarkerFile=JSON.parse(jsonData);var boundingBox=new THREE.Box3;multiMarkerFile.subMarkersControls.forEach(function(item){var poseMatrix=(new THREE.Matrix4).fromArray(item.poseMatrix);var position=new THREE.Vector3;var quaternion=new THREE.Quaternion;var scale=new THREE.Vector3;poseMatrix.decompose(position,quaternion,scale);boundingBox.expandByPoint(position)});return boundingBox};THREEx.ArMultiMarkerControls.prototype.updateSmoothedControls=function(smoothedControls,lerpsValues){if(lerpsValues===undefined){lerpsValues=[[.1,.1,.3],[.2,.1,.4],[.2,.2,.5],[.3,.2,.7],[.3,.2,.7]]}var nVisible=0;this.parameters.subMarkersControls.forEach(function(markerControls,markerIndex){var markerObject3d=markerControls.object3d;if(markerObject3d.visible===true)nVisible++});if(lerpsValues[nVisible-1]!==undefined){var lerpValues=lerpsValues[nVisible-1]}else{var lerpValues=lerpsValues[lerpsValues.length-1]}smoothedControls.parameters.lerpPosition=lerpValues[0];smoothedControls.parameters.lerpQuaternion=lerpValues[1];smoothedControls.parameters.lerpScale=lerpValues[2]};THREEx.ArMultiMarkerControls.fromJSON=function(arToolkitContext,parent3D,markerRoot,jsonData,parameters){var multiMarkerFile=JSON.parse(jsonData);var subMarkersControls=[];var subMarkerPoses=[];parameters=parameters||{};multiMarkerFile.subMarkersControls.forEach(function(item){var markerRoot=new THREE.Object3D;parent3D.add(markerRoot);var subMarkerControls=new THREEx.ArMarkerControls(arToolkitContext,markerRoot,item.parameters);subMarkersControls.push(subMarkerControls);subMarkerPoses.push((new THREE.Matrix4).fromArray(item.poseMatrix))});parameters.subMarkersControls=subMarkersControls;parameters.subMarkerPoses=subMarkerPoses;var multiMarkerControls=new THREEx.ArMultiMarkerControls(arToolkitContext,markerRoot,parameters);return multiMarkerControls};var THREEx=THREEx||{};THREEx.ArMultiMakersLearning=function(arToolkitContext,subMarkersControls){var _this=this;this._arToolkitContext=arToolkitContext;this.subMarkersControls=subMarkersControls;this.enabled=true;arToolkitContext.addEventListener("sourceProcessed",function(){_this._onSourceProcessed()})};THREEx.ArMultiMakersLearning.prototype._onSourceProcessed=function(){var originQuaternion=this.subMarkersControls[0].object3d.quaternion;if(this.enabled===false)return;var visibleMarkerControls=this.subMarkersControls.filter(function(markerControls){return markerControls.object3d.visible===true});var count=Object.keys(visibleMarkerControls).length;var positionDelta=new THREE.Vector3;var quaternionDelta=new THREE.Quaternion;var scaleDelta=new THREE.Vector3;var tmpMatrix=new THREE.Matrix4;for(var i=0;i=1?true:false;if(isLearned===true)return;var otherSubControlsID=_this._getLearnedCoupleStats(subMarkerControls);if(otherSubControlsID===null){return}var otherSubControls=_this._getSubMarkerControlsByID(otherSubControlsID);var seenCoupleStats=subMarkerControls.object3d.userData.seenCouples[otherSubControlsID];var averageMatrix=new THREE.Matrix4;averageMatrix.compose(seenCoupleStats.position.average,seenCoupleStats.quaternion.average,seenCoupleStats.scale.average);var otherAverageMatrix=otherSubControls.object3d.userData.result.averageMatrix;var matrix=(new THREE.Matrix4).getInverse(otherAverageMatrix).multiply(averageMatrix);matrix=(new THREE.Matrix4).getInverse(matrix);console.assert(subMarkerControls.object3d.userData.result===undefined);subMarkerControls.object3d.userData.result={averageMatrix:matrix,confidenceFactor:1};resultChanged=true})}while(resultChanged===true)};THREEx.ArMultiMakersLearning.prototype._getLearnedCoupleStats=function(subMarkerControls){if(subMarkerControls.object3d.userData.seenCouples===undefined)return null;var seenCouples=subMarkerControls.object3d.userData.seenCouples;var coupleControlsIDs=Object.keys(seenCouples).map(Number);for(var i=0;i=1?true:false;if(isLearned===false)continue;return otherSubControlsID}return null};THREEx.ArMultiMakersLearning.prototype._getSubMarkerControlsByID=function(controlsID){for(var i=0;i10*1e3){clearInterval(timerId);return}window.dispatchEvent(new Event("resize"))},1e3/30)});window.addEventListener("resize",onResize);function onResize(){arToolkitSource.onResizeElement();arToolkitSource.copyElementSizeTo(document.body);var buttonElement=document.querySelector(".a-enter-vr");if(buttonElement){buttonElement.style.position="fixed"}}var arToolkitContext=new THREEx.ArToolkitContext(artoolkitProfile.contextParameters);this.arToolkitContext=arToolkitContext;arToolkitContext.init(function onCompleted(){});this.navigateToLearnerPage=function(){var learnerURL=THREEx.ArToolkitContext.baseURL+"examples/multi-markers/examples/learner.html";THREEx.ArMultiMarkerUtils.navigateToLearnerPage(learnerURL,_this.data.trackingBackend)};this.initAreaLearningButton=function(){if(this.data.areaLearningButton===false)return;if(document.querySelector("#arjsAreaLearningButton")!==null)return;var imgElement=document.createElement("img");imgElement.id="arjsAreaLearningButton";imgElement.style.position="fixed";imgElement.style.bottom="16px";imgElement.style.left="16px";imgElement.style.width="48px";imgElement.style.height="48px";imgElement.style.zIndex=1;imgElement.src=THREEx.ArToolkitContext.baseURL+"examples/multi-markers/examples/images/record-start.png";document.body.appendChild(imgElement);imgElement.addEventListener("click",function(){_this.navigateToLearnerPage()})}},tick:function(now,delta){if(this.arToolkitSource.ready===false)return;if(this.arToolkitContext.arController!==null){this.el.sceneEl.camera.projectionMatrix.copy(this.arToolkitContext.getProjectionMatrix())}this.arToolkitContext.update(this.arToolkitSource.domElement)}});AFRAME.registerComponent("arjsmarker",{dependencies:["arjs","artoolkit"],schema:{preset:{type:"string"},markerhelpers:{type:"boolean","default":false},size:{type:"number","default":1},type:{type:"string"},patternUrl:{type:"string"},barcodeValue:{type:"number"},changeMatrixMode:{type:"string","default":"modelViewMatrix"},minConfidence:{type:"number","default":.6}},init:function(){var _this=this;var arjsSystem=this.el.sceneEl.systems.arjs||this.el.sceneEl.systems.artoolkit;var artoolkitContext=arjsSystem.arToolkitContext;var scene=this.el.sceneEl.object3D;if(this.data.preset==="hiro"){this.data.type="pattern";this.data.patternUrl=THREEx.ArToolkitContext.baseURL+"examples/marker-training/examples/pattern-files/pattern-hiro.patt"}else if(this.data.preset==="kanji"){this.data.type="pattern";this.data.patternUrl=THREEx.ArToolkitContext.baseURL+"examples/marker-training/examples/pattern-files/pattern-kanji.patt"}else if(this.data.preset==="area"){this.data.type="area"}else{console.assert(this.data.preset==="","illegal preset value "+this.data.preset)}this._markerRoot=new THREE.Group;scene.add(this._markerRoot);this._arMarkerControls=null;this._multiMarkerControls=null;if(this.data.type==="area"){if(localStorage.getItem("ARjsMultiMarkerFile")===null){THREEx.ArMultiMarkerUtils.storeDefaultMultiMarkerFile(arjsSystem.data.trackingBackend)}console.assert(localStorage.getItem("ARjsMultiMarkerFile")!==null);var multiMarkerFile=localStorage.getItem("ARjsMultiMarkerFile");this._multiMarkerControls=THREEx.ArMultiMarkerControls.fromJSON(artoolkitContext,scene,this._markerRoot,multiMarkerFile,{changeMatrixMode:this.data.changeMatrixMode});console.log("this.data.markerhelpers",this.data.markerhelpers);if(this.data.markerhelpers===true){this._multiMarkerControls.subMarkersControls.forEach(function(subMarkerControls){var markerHelper=new THREEx.ArMarkerHelper(subMarkerControls);scene.add(markerHelper.object3d)})}}else if(this.data.type==="pattern"||this.data.type==="barcode"||this.data.type==="unknown"){this._arMarkerControls=new THREEx.ArMarkerControls(artoolkitContext,this._markerRoot,this.data)}else console.assert(false);this.arSmoothedControls=new THREEx.ArSmoothedControls(this.el.object3D,{lerpPosition:.1,lerpQuaternion:.1,lerpScale:.1});if(this.data.type==="area")arjsSystem.initAreaLearningButton()},remove:function(){},update:function(){},tick:function(){if(this.data.changeMatrixMode==="cameraTransformMatrix"){this.el.sceneEl.object3D.visible=this.el.object3D.visible}if(this._multiMarkerControls!==null){this._multiMarkerControls.updateSmoothedControls(this.arSmoothedControls)}this.arSmoothedControls.update(this._markerRoot)}});AFRAME.registerPrimitive("a-marker",AFRAME.utils.extendDeep({},AFRAME.primitives.getMeshMixin(),{defaultComponents:{arjsmarker:{}},mappings:{type:"arjsmarker.type",size:"arjsmarker.size",url:"arjsmarker.patternUrl",value:"arjsmarker.barcodeValue",preset:"arjsmarker.preset",minConfidence:"arjsmarker.minConfidence",markerhelpers:"arjsmarker.markerhelpers"}}));AFRAME.registerPrimitive("a-marker-camera",AFRAME.utils.extendDeep({},AFRAME.primitives.getMeshMixin(),{defaultComponents:{arjsmarker:{changeMatrixMode:"cameraTransformMatrix"},camera:true},mappings:{type:"arjsmarker.type",size:"arjsmarker.size",url:"arjsmarker.patternUrl",value:"arjsmarker.barcodeValue",preset:"arjsmarker.preset",minConfidence:"arjsmarker.minConfidence",markerhelpers:"arjsmarker.markerhelpers"}}));(function(){"use strict";var ARController=function(width,height,camera){var id;var w=width,h=height;this.orientation="landscape";this.listeners={};if(typeof width!=="number"){var image=width;camera=height;w=image.videoWidth||image.width;h=image.videoHeight||image.height;this.image=image}this.defaultMarkerWidth=1;this.patternMarkers={};this.barcodeMarkers={};this.transform_mat=new Float32Array(16);this.canvas=document.createElement("canvas");this.canvas.width=w;this.canvas.height=h;this.ctx=this.canvas.getContext("2d");this.videoWidth=w;this.videoHeight=h;if(typeof camera==="string"){var self=this;this.cameraParam=new ARCameraParam(camera,function(){self._initialize()},function(err){console.error("ARController: Failed to load ARCameraParam",err)})}else{this.cameraParam=camera;this._initialize()}};ARController.prototype.dispose=function(){artoolkit.teardown(this.id);for(var t in this){this[t]=null}};ARController.prototype.process=function(image){this.detectMarker(image);var markerNum=this.getMarkerNum();var k,o;for(k in this.patternMarkers){o=this.patternMarkers[k];o.inPrevious=o.inCurrent; -o.inCurrent=false}for(k in this.barcodeMarkers){o=this.barcodeMarkers[k];o.inPrevious=o.inCurrent;o.inCurrent=false}for(var i=0;i-1&&(markerInfo.id===markerInfo.idPatt||markerInfo.idMatrix===-1)){visible=this.trackPatternMarkerId(markerInfo.idPatt);markerType=artoolkit.PATTERN_MARKER;if(markerInfo.dir!==markerInfo.dirPatt){this.setMarkerInfoDir(i,markerInfo.dirPatt)}}else if(markerInfo.idMatrix>-1){visible=this.trackBarcodeMarkerId(markerInfo.idMatrix);markerType=artoolkit.BARCODE_MARKER;if(markerInfo.dir!==markerInfo.dirMatrix){this.setMarkerInfoDir(i,markerInfo.dirMatrix)}}if(markerType!==artoolkit.UNKNOWN_MARKER&&visible.inPrevious){this.getTransMatSquareCont(i,visible.markerWidth,visible.matrix,visible.matrix)}else{this.getTransMatSquare(i,visible.markerWidth,visible.matrix)}visible.inCurrent=true;this.transMatToGLMat(visible.matrix,this.transform_mat);this.dispatchEvent({name:"getMarker",target:this,data:{index:i,type:markerType,marker:markerInfo,matrix:this.transform_mat}})}var multiMarkerCount=this.getMultiMarkerCount();for(var i=0;i=0){visible=true;this.dispatchEvent({name:"getMultiMarker",target:this,data:{multiMarkerId:i,matrix:this.transform_mat}});break}}if(visible){for(var j=0;j-1){this.listeners[name].splice(index,1)}}};ARController.prototype.dispatchEvent=function(event){var listeners=this.listeners[event.name];if(listeners){for(var i=0;i-1){writeStringToFS(filename,url,writeCallback)}else{ajax(url,filename,writeCallback)}}function writeStringToFS(target,string,callback){var byteArray=new Uint8Array(string.length);for(var i=0;i1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}else{Module["thisProgram"]="unknown-program"}}Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL){if(!Module["print"])Module["print"]=print;if(typeof printErr!="undefined")Module["printErr"]=printErr;if(typeof read!="undefined"){Module["read"]=read}else{Module["read"]=function read(){throw"no read() available (jsc?)"}}Module["readBinary"]=function readBinary(f){if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}var data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof console!=="undefined"){if(!Module["print"])Module["print"]=function print(x){console.log(x)};if(!Module["printErr"])Module["printErr"]=function printErr(x){console.log(x)}}else{var TRY_USE_DUMP=false;if(!Module["print"])Module["print"]=TRY_USE_DUMP&&typeof dump!=="undefined"?function(x){dump(x)}:function(x){}}if(ENVIRONMENT_IS_WORKER){Module["load"]=importScripts}if(typeof Module["setWindowTitle"]==="undefined"){Module["setWindowTitle"]=function(title){document.title=title}}}else{throw"Unknown runtime environment. Where are we?"}function globalEval(x){eval.call(null,x)}if(!Module["load"]&&Module["read"]){Module["load"]=function load(f){globalEval(Module["read"](f))}}if(!Module["print"]){Module["print"]=function(){}}if(!Module["printErr"]){Module["printErr"]=Module["print"]}if(!Module["arguments"]){Module["arguments"]=[]}if(!Module["thisProgram"]){Module["thisProgram"]="./this.program"}Module.print=Module["print"];Module.printErr=Module["printErr"];Module["preRun"]=[];Module["postRun"]=[];for(var key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}var Runtime={setTempRet0:function(value){tempRet0=value},getTempRet0:function(){return tempRet0},stackSave:function(){return STACKTOP},stackRestore:function(stackTop){STACKTOP=stackTop},getNativeTypeSize:function(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return Runtime.QUANTUM_SIZE}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}},getNativeFieldSize:function(type){return Math.max(Runtime.getNativeTypeSize(type),Runtime.QUANTUM_SIZE)},STACK_ALIGN:16,prepVararg:function(ptr,type){if(type==="double"||type==="i64"){if(ptr&7){assert((ptr&7)===4);ptr+=4}}else{assert((ptr&3)===0)}return ptr},getAlignSize:function(type,size,vararg){if(!vararg&&(type=="i64"||type=="double"))return 8;if(!type)return Math.min(size,8);return Math.min(size||(type?Runtime.getNativeFieldSize(type):0),Runtime.QUANTUM_SIZE)},dynCall:function(sig,ptr,args){if(args&&args.length){if(!args.splice)args=Array.prototype.slice.call(args);args.splice(0,0,ptr);return Module["dynCall_"+sig].apply(null,args)}else{return Module["dynCall_"+sig].call(null,ptr)}},functionPointers:[],addFunction:function(func){for(var i=0;i=TOTAL_MEMORY){var success=enlargeMemory();if(!success){DYNAMICTOP=ret;return 0}}return ret},alignMemory:function(size,quantum){var ret=size=Math.ceil(size/(quantum?quantum:16))*(quantum?quantum:16);return ret},makeBigInt:function(low,high,unsigned){var ret=unsigned?+(low>>>0)+ +(high>>>0)*+4294967296:+(low>>>0)+ +(high|0)*+4294967296;return ret},GLOBAL_BASE:8,QUANTUM_SIZE:4,__dummy__:0};Module["Runtime"]=Runtime;var __THREW__=0;var ABORT=false;var EXITSTATUS=0;var undef=0;var tempValue,tempInt,tempBigInt,tempInt2,tempBigInt2,tempPair,tempBigIntI,tempBigIntR,tempBigIntS,tempBigIntP,tempBigIntD,tempDouble,tempFloat;var tempI64,tempI64b;var tempRet0,tempRet1,tempRet2,tempRet3,tempRet4,tempRet5,tempRet6,tempRet7,tempRet8,tempRet9;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}var globalScope=this;function getCFunc(ident){var func=Module["_"+ident];if(!func){try{func=eval("_"+ident)}catch(e){}}assert(func,"Cannot call unknown function "+ident+" (perhaps LLVM optimizations or closure removed it?)");return func}var cwrap,ccall;(function(){var JSfuncs={stackSave:function(){Runtime.stackSave()},stackRestore:function(){Runtime.stackRestore()},arrayToC:function(arr){var ret=Runtime.stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret},stringToC:function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=Runtime.stackAlloc((str.length<<2)+1);writeStringToMemory(str,ret)}return ret}};var toC={string:JSfuncs["stringToC"],array:JSfuncs["arrayToC"]};ccall=function ccallFunc(ident,returnType,argTypes,args,opts){var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=+1?tempDouble>+0?(Math_min(+Math_floor(tempDouble/+4294967296),+4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/+4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}Module["setValue"]=setValue;function getValue(ptr,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP32[ptr>>2];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];default:abort("invalid type for setValue: "+type)}return null}Module["getValue"]=getValue;var ALLOC_NORMAL=0;var ALLOC_STACK=1;var ALLOC_STATIC=2;var ALLOC_DYNAMIC=3;var ALLOC_NONE=4;Module["ALLOC_NORMAL"]=ALLOC_NORMAL;Module["ALLOC_STACK"]=ALLOC_STACK;Module["ALLOC_STATIC"]=ALLOC_STATIC;Module["ALLOC_DYNAMIC"]=ALLOC_DYNAMIC;Module["ALLOC_NONE"]=ALLOC_NONE;function allocate(slab,types,allocator,ptr){var zeroinit,size;if(typeof slab==="number"){zeroinit=true;size=slab}else{zeroinit=false;size=slab.length}var singleType=typeof types==="string"?types:null;var ret;if(allocator==ALLOC_NONE){ret=ptr}else{ret=[_malloc,Runtime.stackAlloc,Runtime.staticAlloc,Runtime.dynamicAlloc][allocator===undefined?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var ptr=ret,stop;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr>2]=0}stop=ret+size;while(ptr>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return Module["UTF8ToString"](ptr)}Module["Pointer_stringify"]=Pointer_stringify;function AsciiToString(ptr){var str="";while(1){var ch=HEAP8[ptr++>>0]; -if(!ch)return str;str+=String.fromCharCode(ch)}}Module["AsciiToString"]=AsciiToString;function stringToAscii(str,outPtr){return writeAsciiToMemory(str,outPtr,false)}Module["stringToAscii"]=stringToAscii;function UTF8ArrayToString(u8Array,idx){var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}Module["UTF8ArrayToString"]=UTF8ArrayToString;function UTF8ToString(ptr){return UTF8ArrayToString(HEAPU8,ptr)}Module["UTF8ToString"]=UTF8ToString;function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}Module["stringToUTF8Array"]=stringToUTF8Array;function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}Module["stringToUTF8"]=stringToUTF8;function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){++len}else if(u<=2047){len+=2}else if(u<=65535){len+=3}else if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}Module["lengthBytesUTF8"]=lengthBytesUTF8;function UTF16ToString(ptr){var i=0;var str="";while(1){var codeUnit=HEAP16[ptr+i*2>>1];if(codeUnit==0)return str;++i;str+=String.fromCharCode(codeUnit)}}Module["UTF16ToString"]=UTF16ToString;function stringToUTF16(str,outPtr,maxBytesToWrite){if(maxBytesToWrite===undefined){maxBytesToWrite=2147483647}if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite>1]=codeUnit;outPtr+=2}HEAP16[outPtr>>1]=0;return outPtr-startPtr}Module["stringToUTF16"]=stringToUTF16;function lengthBytesUTF16(str){return str.length*2}Module["lengthBytesUTF16"]=lengthBytesUTF16;function UTF32ToString(ptr){var i=0;var str="";while(1){var utf32=HEAP32[ptr+i*4>>2];if(utf32==0)return str;++i;if(utf32>=65536){var ch=utf32-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}else{str+=String.fromCharCode(utf32)}}}Module["UTF32ToString"]=UTF32ToString;function stringToUTF32(str,outPtr,maxBytesToWrite){if(maxBytesToWrite===undefined){maxBytesToWrite=2147483647}if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i=55296&&codeUnit<=57343){var trailSurrogate=str.charCodeAt(++i);codeUnit=65536+((codeUnit&1023)<<10)|trailSurrogate&1023}HEAP32[outPtr>>2]=codeUnit;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr>>2]=0;return outPtr-startPtr}Module["stringToUTF32"]=stringToUTF32;function lengthBytesUTF32(str){var len=0;for(var i=0;i=55296&&codeUnit<=57343)++i;len+=4}return len}Module["lengthBytesUTF32"]=lengthBytesUTF32;function demangle(func){var hasLibcxxabi=!!Module["___cxa_demangle"];if(hasLibcxxabi){try{var buf=_malloc(func.length);writeStringToMemory(func.substr(1),buf);var status=_malloc(4);var ret=Module["___cxa_demangle"](buf,0,0,status);if(getValue(status,"i32")===0&&ret){return Pointer_stringify(ret)}}catch(e){}finally{if(buf)_free(buf);if(status)_free(status);if(ret)_free(ret)}}var i=3;var basicTypes={v:"void",b:"bool",c:"char",s:"short",i:"int",l:"long",f:"float",d:"double",w:"wchar_t",a:"signed char",h:"unsigned char",t:"unsigned short",j:"unsigned int",m:"unsigned long",x:"long long",y:"unsigned long long",z:"..."};var subs=[];var first=true;function dump(x){if(x)Module.print(x);Module.print(func);var pre="";for(var a=0;a"}else{ret=name}paramLoop:while(i0){var c=func[i++];if(c in basicTypes){list.push(basicTypes[c])}else{switch(c){case"P":list.push(parse(true,1,true)[0]+"*");break;case"R":list.push(parse(true,1,true)[0]+"&");break;case"L":{i++;var end=func.indexOf("E",i);var size=end-i;list.push(func.substr(i,size));i+=size+2;break};case"A":{var size=parseInt(func.substr(i));i+=size.toString().length;if(func[i]!=="_")throw"?";i++;list.push(parse(true,1,true)[0]+" ["+size+"]");break};case"E":break paramLoop;default:ret+="?"+c;break paramLoop}}}if(!allowVoid&&list.length===1&&list[0]==="void")list=[];if(rawList){if(ret){list.push(ret+"?")}return list}else{return ret+flushList()}}var parsed=func;try{if(func=="Object._main"||func=="_main"){return"main()"}if(typeof func==="number")func=Pointer_stringify(func);if(func[0]!=="_")return func;if(func[1]!=="_")return func;if(func[2]!=="Z")return func;switch(func[3]){case"n":return"operator new()";case"d":return"operator delete()"}parsed=parse()}catch(e){parsed+="?"}if(parsed.indexOf("?")>=0&&!hasLibcxxabi){Runtime.warnOnce("warning: a problem occurred in builtin C++ name demangling; build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling")}return parsed}function demangleAll(text){return text.replace(/__Z[\w\d_]+/g,function(x){var y=demangle(x);return x===y?x:x+" ["+y+"]"})}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}function stackTrace(){return demangleAll(jsStackTrace())}Module["stackTrace"]=stackTrace;var PAGE_SIZE=4096;function alignMemoryPage(x){if(x%4096>0){x+=4096-x%4096}return x}var HEAP;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var STATIC_BASE=0,STATICTOP=0,staticSealed=false;var STACK_BASE=0,STACKTOP=0,STACK_MAX=0;var DYNAMIC_BASE=0,DYNAMICTOP=0;function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}function enlargeMemory(){abortOnCannotGrowMemory()}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||268435456;var totalMemory=64*1024;while(totalMemory0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Runtime.dynCall("v",func)}else{Runtime.dynCall("vi",func,[callback.arg])}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}Module["addOnPreRun"]=addOnPreRun;function addOnInit(cb){__ATINIT__.unshift(cb)}Module["addOnInit"]=addOnInit;function addOnPreMain(cb){__ATMAIN__.unshift(cb)}Module["addOnPreMain"]=addOnPreMain;function addOnExit(cb){__ATEXIT__.unshift(cb)}Module["addOnExit"]=addOnExit;function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}Module["addOnPostRun"]=addOnPostRun;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}Module["intArrayFromString"]=intArrayFromString;function intArrayToString(array){var ret=[];for(var i=0;i255){chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}Module["intArrayToString"]=intArrayToString;function writeStringToMemory(string,buffer,dontAddNull){var array=intArrayFromString(string,dontAddNull);var i=0;while(i>0]=chr;i=i+1}}Module["writeStringToMemory"]=writeStringToMemory;function writeArrayToMemory(array,buffer){for(var i=0;i>0]=array[i]}}Module["writeArrayToMemory"]=writeArrayToMemory;function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}Module["writeAsciiToMemory"]=writeAsciiToMemory;function unSign(value,bits,ignore){if(value>=0){return value}return bits<=32?2*Math.abs(1<=half&&(bits<=32||value>half)){value=-2*half+value}return value}if(!Math["imul"]||Math["imul"](4294967295,5)!==-5)Math["imul"]=function imul(a,b){var ah=a>>>16;var al=a&65535;var bh=b>>>16;var bl=b&65535;return al*bl+(ah*bl+al*bh<<16)|0};Math.imul=Math["imul"];if(!Math["clz32"])Math["clz32"]=function(x){x=x>>>0;for(var i=0;i<32;i++){if(x&1<<31-i)return i}return 32};Math.clz32=Math["clz32"];var Math_abs=Math.abs;var Math_cos=Math.cos;var Math_sin=Math.sin;var Math_tan=Math.tan;var Math_acos=Math.acos;var Math_asin=Math.asin;var Math_atan=Math.atan;var Math_atan2=Math.atan2;var Math_exp=Math.exp;var Math_log=Math.log;var Math_sqrt=Math.sqrt;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_pow=Math.pow;var Math_imul=Math.imul;var Math_fround=Math.fround;var Math_min=Math.min;var Math_clz32=Math.clz32;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}Module["addRunDependency"]=addRunDependency;function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["removeRunDependency"]=removeRunDependency;Module["preloadedImages"]={};Module["preloadedAudios"]={};var memoryInitializer=null;var ASM_CONSTS=[function($0,$1,$2,$3){{if(!artoolkit["multiEachMarkerInfo"]){artoolkit["multiEachMarkerInfo"]={}}var multiEachMarker=artoolkit["multiEachMarkerInfo"];multiEachMarker["visible"]=$0;multiEachMarker["pattId"]=$1;multiEachMarker["pattType"]=$2;multiEachMarker["width"]=$3}},function($0,$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32){{var $a=arguments;var i=12;if(!artoolkit["markerInfo"]){artoolkit["markerInfo"]={pos:[0,0],line:[[0,0,0],[0,0,0],[0,0,0],[0,0,0]],vertex:[[0,0],[0,0],[0,0],[0,0]]}}var markerInfo=artoolkit["markerInfo"];markerInfo["area"]=$0;markerInfo["id"]=$1;markerInfo["idPatt"]=$2;markerInfo["idMatrix"]=$3;markerInfo["dir"]=$4;markerInfo["dirPatt"]=$5;markerInfo["dirMatrix"]=$6;markerInfo["cf"]=$7;markerInfo["cfPatt"]=$8;markerInfo["cfMatrix"]=$9;markerInfo["pos"][0]=$10;markerInfo["pos"][1]=$11;markerInfo["line"][0][0]=$a[i++];markerInfo["line"][0][1]=$a[i++];markerInfo["line"][0][2]=$a[i++];markerInfo["line"][1][0]=$a[i++];markerInfo["line"][1][1]=$a[i++];markerInfo["line"][1][2]=$a[i++];markerInfo["line"][2][0]=$a[i++];markerInfo["line"][2][1]=$a[i++];markerInfo["line"][2][2]=$a[i++];markerInfo["line"][3][0]=$a[i++];markerInfo["line"][3][1]=$a[i++];markerInfo["line"][3][2]=$a[i++];markerInfo["vertex"][0][0]=$a[i++];markerInfo["vertex"][0][1]=$a[i++];markerInfo["vertex"][1][0]=$a[i++];markerInfo["vertex"][1][1]=$a[i++];markerInfo["vertex"][2][0]=$a[i++];markerInfo["vertex"][2][1]=$a[i++];markerInfo["vertex"][3][0]=$a[i++];markerInfo["vertex"][3][1]=$a[i++];markerInfo["errorCorrected"]=$a[i++]}},function($0,$1,$2,$3,$4){{if(!artoolkit["frameMalloc"]){artoolkit["frameMalloc"]={}}var frameMalloc=artoolkit["frameMalloc"];frameMalloc["framepointer"]=$1;frameMalloc["framesize"]=$2;frameMalloc["camera"]=$3;frameMalloc["transform"]=$4}}];function _emscripten_asm_const_33(code,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32){return ASM_CONSTS[code](a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32)}function _emscripten_asm_const_4(code,a0,a1,a2,a3){return ASM_CONSTS[code](a0,a1,a2,a3)}function _emscripten_asm_const_5(code,a0,a1,a2,a3,a4){return ASM_CONSTS[code](a0,a1,a2,a3,a4)}STATIC_BASE=8;STATICTOP=STATIC_BASE+16496;__ATINIT__.push({func:function(){__GLOBAL__sub_I_ARToolKitJS_cpp()}},{func:function(){__GLOBAL__sub_I_bind_cpp()}});allocate([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,9,0,0,53,42,0,0,0,0,0,0,1,0,0,0,128,1,0,0,0,0,0,0,228,8,0,0,116,42,0,0,52,9,0,0,136,47,0,0,0,0,0,0,1,0,0,0,128,1,0,0,0,0,0,0,52,9,0,0,73,47,0,0,0,0,0,0,1,0,0,0,128,1,0,0,0,0,0,0,228,8,0,0,54,47,0,0,228,8,0,0,23,47,0,0,228,8,0,0,62,46,0,0,228,8,0,0,31,46,0,0,228,8,0,0,0,46,0,0,228,8,0,0,225,45,0,0,228,8,0,0,194,45,0,0,228,8,0,0,93,46,0,0,228,8,0,0,124,46,0,0,228,8,0,0,155,46,0,0,228,8,0,0,186,46,0,0,228,8,0,0,217,46,0,0,228,8,0,0,248,46,0,0,12,9,0,0,199,47,0,0,48,2,0,0,0,0,0,0,228,8,0,0,212,47,0,0,228,8,0,0,225,47,0,0,12,9,0,0,238,47,0,0,56,2,0,0,0,0,0,0,12,9,0,0,15,48,0,0,64,2,0,0,0,0,0,0,12,9,0,0,49,48,0,0,64,2,0,0,0,0,0,0,200,8,0,0,89,48,0,0,200,8,0,0,91,48,0,0,200,8,0,0,93,48,0,0,200,8,0,0,95,48,0,0,200,8,0,0,97,48,0,0,200,8,0,0,99,48,0,0,200,8,0,0,101,48,0,0,200,8,0,0,103,48,0,0,200,8,0,0,105,48,0,0,200,8,0,0,107,48,0,0,200,8,0,0,109,48,0,0,200,8,0,0,111,48,0,0,200,8,0,0,113,48,0,0,12,9,0,0,115,48,0,0,80,2,0,0,0,0,0,0,12,9,0,0,152,48,0,0,80,2,0,0,0,0,0,0,255,15,0,0,6,16,0,0,18,16,0,0,28,16,0,0,255,255,255,255,255,255,255,255,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,1,0,0,0,2,0,0,0,4,0,0,0,8,0,0,0,3,0,0,0,6,0,0,0,12,0,0,0,11,0,0,0,5,0,0,0,10,0,0,0,7,0,0,0,14,0,0,0,15,0,0,0,13,0,0,0,9,0,0,0,1,0,0,0,2,0,0,0,4,0,0,0,8,0,0,0,16,0,0,0,32,0,0,0,64,0,0,0,3,0,0,0,6,0,0,0,12,0,0,0,24,0,0,0,48,0,0,0,96,0,0,0,67,0,0,0,5,0,0,0,10,0,0,0,20,0,0,0,40,0,0,0,80,0,0,0,35,0,0,0,70,0,0,0,15,0,0,0,30,0,0,0,60,0,0,0,120,0,0,0,115,0,0,0,101,0,0,0,73,0,0,0,17,0,0,0,34,0,0,0,68,0,0,0,11,0,0,0,22,0,0,0,44,0,0,0,88,0,0,0,51,0,0,0,102,0,0,0,79,0,0,0,29,0,0,0,58,0,0,0,116,0,0,0,107,0,0,0,85,0,0,0,41,0,0,0,82,0,0,0,39,0,0,0,78,0,0,0,31,0,0,0,62,0,0,0,124,0,0,0,123,0,0,0,117,0,0,0,105,0,0,0,81,0,0,0,33,0,0,0,66,0,0,0,7,0,0,0,14,0,0,0,28,0,0,0,56,0,0,0,112,0,0,0,99,0,0,0,69,0,0,0,9,0,0,0,18,0,0,0,36,0,0,0,72,0,0,0,19,0,0,0,38,0,0,0,76,0,0,0,27,0,0,0,54,0,0,0,108,0,0,0,91,0,0,0,53,0,0,0,106,0,0,0,87,0,0,0,45,0,0,0,90,0,0,0,55,0,0,0,110,0,0,0,95,0,0,0,61,0,0,0,122,0,0,0,119,0,0,0,109,0,0,0,89,0,0,0,49,0,0,0,98,0,0,0,71,0,0,0,13,0,0,0,26,0,0,0,52,0,0,0,104,0,0,0,83,0,0,0,37,0,0,0,74,0,0,0,23,0,0,0,46,0,0,0,92,0,0,0,59,0,0,0,118,0,0,0,111,0,0,0,93,0,0,0,57,0,0,0,114,0,0,0,103,0,0,0,77,0,0,0,25,0,0,0,50,0,0,0,100,0,0,0,75,0,0,0,21,0,0,0,42,0,0,0,84,0,0,0,43,0,0,0,86,0,0,0,47,0,0,0,94,0,0,0,63,0,0,0,126,0,0,0,127,0,0,0,125,0,0,0,121,0,0,0,113,0,0,0,97,0,0,0,65,0,0,0,255,255,255,255,0,0,0,0,1,0,0,0,4,0,0,0,2,0,0,0,8,0,0,0,5,0,0,0,10,0,0,0,3,0,0,0,14,0,0,0,9,0,0,0,7,0,0,0,6,0,0,0,13,0,0,0,11,0,0,0,12,0,0,0,255,255,255,255,0,0,0,0,1,0,0,0,7,0,0,0,2,0,0,0,14,0,0,0,8,0,0,0,56,0,0,0,3,0,0,0,63,0,0,0,15,0,0,0,31,0,0,0,9,0,0,0,90,0,0,0,57,0,0,0,21,0,0,0,4,0,0,0,28,0,0,0,64,0,0,0,67,0,0,0,16,0,0,0,112,0,0,0,32,0,0,0,97,0,0,0,10,0,0,0,108,0,0,0,91,0,0,0,70,0,0,0,58,0,0,0,38,0,0,0,22,0,0,0,47,0,0,0,5,0,0,0,54,0,0,0,29,0,0,0,19,0,0,0,65,0,0,0,95,0,0,0,68,0,0,0,45,0,0,0,17,0,0,0,43,0,0,0,113,0,0,0,115,0,0,0,33,0,0,0,77,0,0,0,98,0,0,0,117,0,0,0,11,0,0,0,87,0,0,0,109,0,0,0,35,0,0,0,92,0,0,0,74,0,0,0,71,0,0,0,79,0,0,0,59,0,0,0,104,0,0,0,39,0,0,0,100,0,0,0,23,0,0,0,82,0,0,0,48,0,0,0,119,0,0,0,6,0,0,0,126,0,0,0,55,0,0,0,13,0,0,0,30,0,0,0,62,0,0,0,20,0,0,0,89,0,0,0,66,0,0,0,27,0,0,0,96,0,0,0,111,0,0,0,69,0,0,0,107,0,0,0,46,0,0,0,37,0,0,0,18,0,0,0,53,0,0,0,44,0,0,0,94,0,0,0,114,0,0,0,42,0,0,0,116,0,0,0,76,0,0,0,34,0,0,0,86,0,0,0,78,0,0,0,73,0,0,0,99,0,0,0,103,0,0,0,118,0,0,0,81,0,0,0,12,0,0,0,125,0,0,0,88,0,0,0,61,0,0,0,110,0,0,0,26,0,0,0,36,0,0,0,106,0,0,0,93,0,0,0,52,0,0,0,75,0,0,0,41,0,0,0,72,0,0,0,85,0,0,0,80,0,0,0,102,0,0,0,60,0,0,0,124,0,0,0,105,0,0,0,25,0,0,0,40,0,0,0,51,0,0,0,101,0,0,0,84,0,0,0,24,0,0,0,123,0,0,0,83,0,0,0,50,0,0,0,49,0,0,0,122,0,0,0,120,0,0,0,121,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,136,0,0,0,5,0,0,0,144,0,0,0,6,0,0,0,152,0,0,0,9,0,0,0,176,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,253,255,255,255,254,255,255,255,0,0,0,0,112,2,0,0,168,2,0,0,200,2,0,0,112,2,0,0,168,2,0,0,168,2,0,0,208,2,0,0,168,2,0,0,112,2,0,0,168,2,0,0,208,2,0,0,168,2,0,0,112,2,0,0,168,2,0,0,168,2,0,0,104,1,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,104,1,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,0,0,0,0,32,2,0,0,1,0,0,0,2,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,96,2,0,0,3,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,1,0,0,0,0,0,0,0,80,2,0,0,3,0,0,0,7,0,0,0,5,0,0,0,6,0,0,0,2,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,216,2,0,0,3,0,0,0,8,0,0,0,5,0,0,0,6,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,232,2,0,0,3,0,0,0,9,0,0,0,5,0,0,0,6,0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,192,3,0,0,192,4,0,0,192,5,0,0,192,6,0,0,192,7,0,0,192,8,0,0,192,9,0,0,192,10,0,0,192,11,0,0,192,12,0,0,192,13,0,0,192,14,0,0,192,15,0,0,192,16,0,0,192,17,0,0,192,18,0,0,192,19,0,0,192,20,0,0,192,21,0,0,192,22,0,0,192,23,0,0,192,24,0,0,192,25,0,0,192,26,0,0,192,27,0,0,192,28,0,0,192,29,0,0,192,30,0,0,192,31,0,0,192,0,0,0,179,1,0,0,195,2,0,0,195,3,0,0,195,4,0,0,195,5,0,0,195,6,0,0,195,7,0,0,195,8,0,0,195,9,0,0,195,10,0,0,195,11,0,0,195,12,0,0,195,13,0,0,211,14,0,0,195,15,0,0,195,0,0,12,187,1,0,12,195,2,0,12,195,3,0,12,195,4,0,12,211,240,10,0,0,96,11,0,0,0,0,0,0,10,0,0,0,100,0,0,0,232,3,0,0,16,39,0,0,160,134,1,0,64,66,15,0,128,150,152,0,0,225,245,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,5,0,0,0,81,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,5,0,0,0,73,58,0,0,0,4,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,5,0,0,0,7,0,0,0,11,0,0,0,13,0,0,0,17,0,0,0,19,0,0,0,23,0,0,0,29,0,0,0,31,0,0,0,37,0,0,0,41,0,0,0,43,0,0,0,47,0,0,0,53,0,0,0,59,0,0,0,61,0,0,0,67,0,0,0,71,0,0,0,73,0,0,0,79,0,0,0,83,0,0,0,89,0,0,0,97,0,0,0,101,0,0,0,103,0,0,0,107,0,0,0,109,0,0,0,113,0,0,0,127,0,0,0,131,0,0,0,137,0,0,0,139,0,0,0,149,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,167,0,0,0,173,0,0,0,179,0,0,0,181,0,0,0,191,0,0,0,193,0,0,0,197,0,0,0,199,0,0,0,211,0,0,0,1,0,0,0,11,0,0,0,13,0,0,0,17,0,0,0,19,0,0,0,23,0,0,0,29,0,0,0,31,0,0,0,37,0,0,0,41,0,0,0,43,0,0,0,47,0,0,0,53,0,0,0,59,0,0,0,61,0,0,0,67,0,0,0,71,0,0,0,73,0,0,0,79,0,0,0,83,0,0,0,89,0,0,0,97,0,0,0,101,0,0,0,103,0,0,0,107,0,0,0,109,0,0,0,113,0,0,0,121,0,0,0,127,0,0,0,131,0,0,0,137,0,0,0,139,0,0,0,143,0,0,0,149,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,167,0,0,0,169,0,0,0,173,0,0,0,179,0,0,0,181,0,0,0,187,0,0,0,191,0,0,0,193,0,0,0,197,0,0,0,199,0,0,0,209,0,0,0,69,114,114,111,114,58,32,108,97,98,101,108,105,110,103,32,119,111,114,107,32,111,118,101,114,102,108,111,119,46,10,0,69,114,114,111,114,58,32,85,110,115,117,112,112,111,114,116,101,100,32,112,105,120,101,108,32,102,111,114,109,97,116,32,40,37,100,41,32,114,101,113,117,101,115,116,101,100,46,10,0,85,110,107,110,111,119,110,32,111,114,32,117,110,115,117,112,112,111,114,116,101,100,32,108,97,98,101,108,105,110,103,32,116,104,114,101,115,104,111,108,100,32,109,111,100,101,32,114,101,113,117,101,115,116,101,100,46,32,83,101,116,32,116,111,32,109,97,110,117,97,108,46,10,0,76,97,98,101,108,105,110,103,32,116,104,114,101,115,104,111,108,100,32,109,111,100,101,32,115,101,116,32,116,111,32,37,115,46,10,0,77,65,78,85,65,76,0,65,85,84,79,95,77,69,68,73,65,78,0,65,85,84,79,95,79,84,83,85,0,65,85,84,79,95,65,68,65,80,84,73,86,69,65,85,84,79,95,66,82,65,67,75,69,84,73,78,71,0,65,117,116,111,32,116,104,114,101,115,104,111,108,100,32,40,98,114,97,99,107,101,116,41,32,109,97,114,107,101,114,32,99,111,117,110,116,115,32,45,91,37,51,100,58,32,37,51,100,93,32,91,37,51,100,58,32,37,51,100,93,32,91,37,51,100,58,32,37,51,100,93,43,46,10,0,65,117,116,111,32,116,104,114,101,115,104,111,108,100,32,40,98,114,97,99,107,101,116,41,32,97,100,106,117,115,116,101,100,32,116,104,114,101,115,104,111,108,100,32,116,111,32,37,100,46,10,0,109,101,100,105,97,110,0,79,116,115,117,0,65,117,116,111,32,116,104,114,101,115,104,111,108,100,32,40,37,115,41,32,97,100,106,117,115,116,101,100,32,116,104,114,101,115,104,111,108,100,32,116,111,32,37,100,46,10,0,63,63,63,32,49,10,0,63,63,63,32,50,10,0,63,63,63,32,51,10,0,69,114,114,111,114,58,32,85,110,115,117,112,112,111,114,116,101,100,32,112,105,120,101,108,32,102,111,114,109,97,116,32,112,97,115,115,101,100,32,116,111,32,97,114,73,109,97,103,101,80,114,111,99,72,105,115,116,40,41,46,10,0,0,0,0,1,0,1,1,1,0,2,4,255,255,5,3,1,0,2,255,6,7,255,3,1,2,2,3,2,3,2,3,3,0,255,4,6,7,5,255,1,4,5,4,4,5,5,4,5,7,6,6,6,7,7,7,6,255,2,4,6,7,5,3,255,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,1,1,0,1,1,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,0,1,1,0,1,1,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,255,255,3,255,5,6,255,255,9,10,255,12,255,255,15,255,17,18,255,20,255,255,23,24,255,255,27,255,29,30,255,255,1,2,255,4,255,255,7,8,255,255,11,255,13,14,255,16,255,255,19,255,21,22,255,255,25,26,255,28,255,255,31,69,114,114,111,114,58,32,117,110,115,117,112,112,111,114,116,101,100,32,112,105,120,101,108,32,102,111,114,109,97,116,46,10,0,69,114,114,111,114,58,32,78,85,76,76,32,112,97,116,116,72,97,110,100,108,101,46,10,0,69,114,114,111,114,58,32,99,97,110,39,116,32,108,111,97,100,32,112,97,116,116,101,114,110,32,102,114,111,109,32,78,85,76,76,32,98,117,102,102,101,114,46,10,0,69,114,114,111,114,58,32,111,117,116,32,111,102,32,109,101,109,111,114,121,46,10,0,32,9,10,13,0,80,97,116,116,101,114,110,32,68,97,116,97,32,114,101,97,100,32,101,114,114,111,114,33,33,10,0,69,114,114,111,114,32,111,112,101,110,105,110,103,32,112,97,116,116,101,114,110,32,102,105,108,101,32,39,37,115,39,32,102,111,114,32,114,101,97,100,105,110,103,46,10,0,69,114,114,111,114,32,114,101,97,100,105,110,103,32,112,97,116,116,101,114,110,32,102,105,108,101,32,39,37,115,39,46,10,0,114,98,0,69,114,114,111,114,32,40,37,100,41,58,32,117,110,97,98,108,101,32,116,111,32,111,112,101,110,32,99,97,109,101,114,97,32,112,97,114,97,109,101,116,101,114,115,32,102,105,108,101,32,34,37,115,34,32,102,111,114,32,114,101,97,100,105,110,103,46,10,0,69,114,114,111,114,32,40,37,100,41,58,32,117,110,97,98,108,101,32,116,111,32,100,101,116,101,114,109,105,110,101,32,102,105,108,101,32,108,101,110,103,116,104,46,0,69,114,114,111,114,58,32,115,117,112,112,108,105,101,100,32,102,105,108,101,32,100,111,101,115,32,110,111,116,32,97,112,112,101,97,114,32,116,111,32,98,101,32,97,110,32,65,82,84,111,111,108,75,105,116,32,99,97,109,101,114,97,32,112,97,114,97,109,101,116,101,114,32,102,105,108,101,46,10,0,69,114,114,111,114,32,40,37,100,41,58,32,117,110,97,98,108,101,32,116,111,32,114,101,97,100,32,102,114,111,109,32,102,105,108,101,46,0,69,114,114,111,114,58,32,105,99,112,71,101,116,74,95,85,95,88,99,0,69,114,114,111,114,58,32,109,97,108,108,111,99,10,0,69,114,114,111,114,32,49,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,50,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,51,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,52,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,53,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,54,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,55,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,114,0,69,114,114,111,114,58,32,117,110,97,98,108,101,32,116,111,32,111,112,101,110,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,46,10,0,37,115,37,115,10,0,0,37,100,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,58,32,70,105,114,115,116,32,108,105,110,101,32,109,117,115,116,32,98,101,32,110,117,109,98,101,114,32,111,102,32,109,97,114,107,101,114,32,99,111,110,102,105,103,115,32,116,111,32,114,101,97,100,46,10,0,79,117,116,32,111,102,32,109,101,109,111,114,121,33,33,10,0,37,108,108,117,37,99,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,58,32,112,97,116,116,101,114,110,32,39,37,115,39,32,115,112,101,99,105,102,105,101,100,32,105,110,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,117,114,97,116,105,111,110,32,119,104,105,108,101,32,105,110,32,98,97,114,99,111,100,101,45,111,110,108,121,32,109,111,100,101,46,10,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,58,32,85,110,97,98,108,101,32,116,111,32,100,101,116,101,114,109,105,110,101,32,100,105,114,101,99,116,111,114,121,32,110,97,109,101,46,10,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,58,32,85,110,97,98,108,101,32,116,111,32,108,111,97,100,32,112,97,116,116,101,114,110,32,39,37,115,39,46,10,0,37,108,102,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,44,32,109,97,114,107,101,114,32,100,101,102,105,110,105,116,105,111,110,32,37,51,100,58,32,70,105,114,115,116,32,108,105,110,101,32,109,117,115,116,32,98,101,32,112,97,116,116,101,114,110,32,119,105,100,116,104,46,10,0,37,108,102,32,37,108,102,32,37,108,102,32,37,108,102,0,37,102,32,37,102,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,44,32,109,97,114,107,101,114,32,100,101,102,105,110,105,116,105,111,110,32,37,51,100,58,32,76,105,110,101,115,32,50,32,45,32,52,32,109,117,115,116,32,98,101,32,109,97,114,107,101,114,32,116,114,97,110,115,102,111,114,109,46,10,0,97,114,103,108,67,97,109,101,114,97,70,114,117,115,116,117,109,40,41,58,32,97,114,80,97,114,97,109,68,101,99,111,109,112,77,97,116,40,41,32,105,110,100,105,99,97,116,101,100,32,112,97,114,97,109,101,116,101,114,32,101,114,114,111,114,46,10,0,108,111,97,100,67,97,109,101,114,97,40,41,58,32,69,114,114,111,114,32,108,111,97,100,105,110,103,32,112,97,114,97,109,101,116,101,114,32,102,105,108,101,32,37,115,32,102,111,114,32,99,97,109,101,114,97,46,10,0,42,42,42,32,67,97,109,101,114,97,32,80,97,114,97,109,101,116,101,114,32,114,101,115,105,122,101,100,32,102,114,111,109,32,37,100,44,32,37,100,46,32,42,42,42,10,0,115,101,116,67,97,109,101,114,97,40,41,58,32,69,114,114,111,114,58,32,97,114,80,97,114,97,109,76,84,67,114,101,97,116,101,46,10,0,115,101,116,67,97,109,101,114,97,40,41,58,32,69,114,114,111,114,58,32,97,114,67,114,101,97,116,101,72,97,110,100,108,101,46,10,0,115,101,116,67,97,109,101,114,97,40,41,58,32,69,114,114,111,114,32,99,114,101,97,116,105,110,103,32,51,68,32,104,97,110,100,108,101,0,108,111,97,100,77,97,114,107,101,114,40,41,58,32,69,114,114,111,114,32,108,111,97,100,105,110,103,32,112,97,116,116,101,114,110,32,102,105,108,101,32,37,115,46,10,0,65,82,84,111,111,108,75,105,116,74,83,40,41,58,32,85,110,97,98,108,101,32,116,111,32,115,101,116,32,117,112,32,65,82,32,109,97,114,107,101,114,46,10,0,99,111,110,102,105,103,32,100,97,116,97,32,108,111,97,100,32,101,114,114,111,114,32,33,33,10,0,65,82,84,111,111,108,75,105,116,74,83,40,41,58,32,85,110,97,98,108,101,32,116,111,32,115,101,116,32,117,112,32,65,82,32,109,117,108,116,105,109,97,114,107,101,114,46,10,0,80,97,116,116,101,114,110,32,100,101,116,101,99,116,105,111,110,32,109,111,100,101,32,115,101,116,32,116,111,32,37,100,46,10,0,80,97,116,116,101,114,110,32,114,97,116,105,111,32,115,105,122,101,32,115,101,116,32,116,111,32,37,102,46,10,0,76,97,98,101,108,105,110,103,32,109,111,100,101,32,115,101,116,32,116,111,32,37,100,10,0,84,104,114,101,115,104,111,108,100,32,115,101,116,32,116,111,32,37,100,10,0,84,104,114,101,115,104,111,108,100,32,109,111,100,101,32,115,101,116,32,116,111,32,37,100,10,0,111,110,46,0,111,102,102,46,0,68,101,98,117,103,32,109,111,100,101,32,115,101,116,32,116,111,32,37,115,10,0,73,109,97,103,101,32,112,114,111,99,46,32,109,111,100,101,32,115,101,116,32,116,111,32,37,100,46,10,0,123,32,105,102,32,40,33,97,114,116,111,111,108,107,105,116,91,34,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,73,110,102,111,34,93,41,32,123,32,97,114,116,111,111,108,107,105,116,91,34,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,73,110,102,111,34,93,32,61,32,40,123,125,41,59,32,125,32,118,97,114,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,32,61,32,97,114,116,111,111,108,107,105,116,91,34,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,73,110,102,111,34,93,59,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,91,39,118,105,115,105,98,108,101,39,93,32,61,32,36,48,59,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,91,39,112,97,116,116,73,100,39,93,32,61,32,36,49,59,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,91,39,112,97,116,116,84,121,112,101,39,93,32,61,32,36,50,59,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,91,39,119,105,100,116,104,39,93,32,61,32,36,51,59,32,125,0,123,32,118,97,114,32,36,97,32,61,32,97,114,103,117,109,101,110,116,115,59,32,118,97,114,32,105,32,61,32,49,50,59,32,105,102,32,40,33,97,114,116,111,111,108,107,105,116,91,34,109,97,114,107,101,114,73,110,102,111,34,93,41,32,123,32,97,114,116,111,111,108,107,105,116,91,34,109,97,114,107,101,114,73,110,102,111,34,93,32,61,32,40,123,32,112,111,115,58,32,91,48,44,48,93,44,32,108,105,110,101,58,32,91,91,48,44,48,44,48,93,44,32,91,48,44,48,44,48,93,44,32,91,48,44,48,44,48,93,44,32,91,48,44,48,44,48,93,93,44,32,118,101,114,116,101,120,58,32,91,91,48,44,48,93,44,32,91,48,44,48,93,44,32,91,48,44,48,93,44,32,91,48,44,48,93,93,32,125,41,59,32,125,32,118,97,114,32,109,97,114,107,101,114,73,110,102,111,32,61,32,97,114,116,111,111,108,107,105,116,91,34,109,97,114,107,101,114,73,110,102,111,34,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,97,114,101,97,34,93,32,61,32,36,48,59,32,109,97,114,107,101,114,73,110,102,111,91,34,105,100,34,93,32,61,32,36,49,59,32,109,97,114,107,101,114,73,110,102,111,91,34,105,100,80,97,116,116,34,93,32,61,32,36,50,59,32,109,97,114,107,101,114,73,110,102,111,91,34,105,100,77,97,116,114,105,120,34,93,32,61,32,36,51,59,32,109,97,114,107,101,114,73,110,102,111,91,34,100,105,114,34,93,32,61,32,36,52,59,32,109,97,114,107,101,114,73,110,102,111,91,34,100,105,114,80,97,116,116,34,93,32,61,32,36,53,59,32,109,97,114,107,101,114,73,110,102,111,91,34,100,105,114,77,97,116,114,105,120,34,93,32,61,32,36,54,59,32,109,97,114,107,101,114,73,110,102,111,91,34,99,102,34,93,32,61,32,36,55,59,32,109,97,114,107,101,114,73,110,102,111,91,34,99,102,80,97,116,116,34,93,32,61,32,36,56,59,32,109,97,114,107,101,114,73,110,102,111,91,34,99,102,77,97,116,114,105,120,34,93,32,61,32,36,57,59,32,109,97,114,107,101,114,73,110,102,111,91,34,112,111,115,34,93,91,48,93,32,61,32,36,49,48,59,32,109,97,114,107,101,114,73,110,102,111,91,34,112,111,115,34,93,91,49,93,32,61,32,36,49,49,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,48,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,48,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,48,93,91,50,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,49,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,49,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,49,93,91,50,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,50,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,50,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,50,93,91,50,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,51,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,51,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,51,93,91,50,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,48,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,48,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,49,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,49,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,50,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,50,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,51,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,51,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,101,114,114,111,114,67,111,114,114,101,99,116,101,100,34,93,32,61,32,36,97,91,105,43,43,93,59,32,125,0,115,101,116,117,112,40,41,58,32,69,114,114,111,114,58,32,97,114,80,97,116,116,67,114,101,97,116,101,72,97,110,100,108,101,46,10,0,65,108,108,111,99,97,116,101,100,32,118,105,100,101,111,70,114,97,109,101,83,105,122,101,32,37,100,10,0,123,32,105,102,32,40,33,97,114,116,111,111,108,107,105,116,91,34,102,114,97,109,101,77,97,108,108,111,99,34,93,41,32,123,32,97,114,116,111,111,108,107,105,116,91,34,102,114,97,109,101,77,97,108,108,111,99,34,93,32,61,32,40,123,125,41,59,32,125,32,118,97,114,32,102,114,97,109,101,77,97,108,108,111,99,32,61,32,97,114,116,111,111,108,107,105,116,91,34,102,114,97,109,101,77,97,108,108,111,99,34,93,59,32,102,114,97,109,101,77,97,108,108,111,99,91,34,102,114,97,109,101,112,111,105,110,116,101,114,34,93,32,61,32,36,49,59,32,102,114,97,109,101,77,97,108,108,111,99,91,34,102,114,97,109,101,115,105,122,101,34,93,32,61,32,36,50,59,32,102,114,97,109,101,77,97,108,108,111,99,91,34,99,97,109,101,114,97,34,93,32,61,32,36,51,59,32,102,114,97,109,101,77,97,108,108,111,99,91,34,116,114,97,110,115,102,111,114,109,34,93,32,61,32,36,52,59,32,125,0,115,101,116,117,112,0,116,101,97,114,100,111,119,110,0,95,97,100,100,77,97,114,107,101,114,0,95,97,100,100,77,117,108,116,105,77,97,114,107,101,114,0,103,101,116,77,117,108,116,105,77,97,114,107,101,114,78,117,109,0,103,101,116,77,117,108,116,105,77,97,114,107,101,114,67,111,117,110,116,0,95,108,111,97,100,67,97,109,101,114,97,0,115,101,116,77,97,114,107,101,114,73,110,102,111,68,105,114,0,115,101,116,77,97,114,107,101,114,73,110,102,111,86,101,114,116,101,120,0,103,101,116,84,114,97,110,115,77,97,116,83,113,117,97,114,101,0,103,101,116,84,114,97,110,115,77,97,116,83,113,117,97,114,101,67,111,110,116,0,103,101,116,84,114,97,110,115,77,97,116,77,117,108,116,105,83,113,117,97,114,101,0,103,101,116,84,114,97,110,115,77,97,116,77,117,108,116,105,83,113,117,97,114,101,82,111,98,117,115,116,0,100,101,116,101,99,116,77,97,114,107,101,114,0,103,101,116,77,97,114,107,101,114,78,117,109,0,103,101,116,77,117,108,116,105,69,97,99,104,77,97,114,107,101,114,0,103,101,116,77,97,114,107,101,114,0,115,101,116,68,101,98,117,103,77,111,100,101,0,103,101,116,68,101,98,117,103,77,111,100,101,0,103,101,116,80,114,111,99,101,115,115,105,110,103,73,109,97,103,101,0,115,101,116,76,111,103,76,101,118,101,108,0,103,101,116,76,111,103,76,101,118,101,108,0,115,101,116,80,114,111,106,101,99,116,105,111,110,78,101,97,114,80,108,97,110,101,0,103,101,116,80,114,111,106,101,99,116,105,111,110,78,101,97,114,80,108,97,110,101,0,115,101,116,80,114,111,106,101,99,116,105,111,110,70,97,114,80,108,97,110,101,0,103,101,116,80,114,111,106,101,99,116,105,111,110,70,97,114,80,108,97,110,101,0,115,101,116,84,104,114,101,115,104,111,108,100,77,111,100,101,0,103,101,116,84,104,114,101,115,104,111,108,100,77,111,100,101,0,115,101,116,84,104,114,101,115,104,111,108,100,0,103,101,116,84,104,114,101,115,104,111,108,100,0,115,101,116,80,97,116,116,101,114,110,68,101,116,101,99,116,105,111,110,77,111,100,101,0,103,101,116,80,97,116,116,101,114,110,68,101,116,101,99,116,105,111,110,77,111,100,101,0,115,101,116,80,97,116,116,82,97,116,105,111,0,103,101,116,80,97,116,116,82,97,116,105,111,0,115,101,116,77,97,116,114,105,120,67,111,100,101,84,121,112,101,0,103,101,116,77,97,116,114,105,120,67,111,100,101,84,121,112,101,0,115,101,116,76,97,98,101,108,105,110,103,77,111,100,101,0,103,101,116,76,97,98,101,108,105,110,103,77,111,100,101,0,115,101,116,73,109,97,103,101,80,114,111,99,77,111,100,101,0,103,101,116,73,109,97,103,101,80,114,111,99,77,111,100,101,0,69,82,82,79,82,95,65,82,67,79,78,84,82,79,76,76,69,82,95,78,79,84,95,70,79,85,78,68,0,69,82,82,79,82,95,77,85,76,84,73,77,65,82,75,69,82,95,78,79,84,95,70,79,85,78,68,0,69,82,82,79,82,95,77,65,82,75,69,82,95,73,78,68,69,88,95,79,85,84,95,79,70,95,66,79,85,78,68,83,0,65,82,95,68,69,66,85,71,95,68,73,83,65,66,76,69,0,65,82,95,68,69,66,85,71,95,69,78,65,66,76,69,0,65,82,95,68,69,70,65,85,76,84,95,68,69,66,85,71,95,77,79,68,69,0,65,82,95,76,65,66,69,76,73,78,71,95,87,72,73,84,69,95,82,69,71,73,79,78,0,65,82,95,76,65,66,69,76,73,78,71,95,66,76,65,67,75,95,82,69,71,73,79,78,0,65,82,95,68,69,70,65,85,76,84,95,76,65,66,69,76,73,78,71,95,77,79,68,69,0,65,82,95,68,69,70,65,85,76,84,95,76,65,66,69,76,73,78,71,95,84,72,82,69,83,72,0,65,82,95,73,77,65,71,69,95,80,82,79,67,95,70,82,65,77,69,95,73,77,65,71,69,0,65,82,95,73,77,65,71,69,95,80,82,79,67,95,70,73,69,76,68,95,73,77,65,71,69,0,65,82,95,68,69,70,65,85,76,84,95,73,77,65,71,69,95,80,82,79,67,95,77,79,68,69,0,65,82,95,84,69,77,80,76,65,84,69,95,77,65,84,67,72,73,78,71,95,67,79,76,79,82,0,65,82,95,84,69,77,80,76,65,84,69,95,77,65,84,67,72,73,78,71,95,77,79,78,79,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,68,69,84,69,67,84,73,79,78,0,65,82,95,84,69,77,80,76,65,84,69,95,77,65,84,67,72,73,78,71,95,67,79,76,79,82,95,65,78,68,95,77,65,84,82,73,88,0,65,82,95,84,69,77,80,76,65,84,69,95,77,65,84,67,72,73,78,71,95,77,79,78,79,95,65,78,68,95,77,65,84,82,73,88,0,65,82,95,68,69,70,65,85,76,84,95,80,65,84,84,69,82,78,95,68,69,84,69,67,84,73,79,78,95,77,79,68,69,0,65,82,95,85,83,69,95,84,82,65,67,75,73,78,71,95,72,73,83,84,79,82,89,0,65,82,95,78,79,85,83,69,95,84,82,65,67,75,73,78,71,95,72,73,83,84,79,82,89,0,65,82,95,85,83,69,95,84,82,65,67,75,73,78,71,95,72,73,83,84,79,82,89,95,86,50,0,65,82,95,68,69,70,65,85,76,84,95,77,65,82,75,69,82,95,69,88,84,82,65,67,84,73,79,78,95,77,79,68,69,0,65,82,95,77,65,88,95,76,79,79,80,95,67,79,85,78,84,0,65,82,95,76,79,79,80,95,66,82,69,65,75,95,84,72,82,69,83,72,0,65,82,95,76,79,71,95,76,69,86,69,76,95,68,69,66,85,71,0,65,82,95,76,79,71,95,76,69,86,69,76,95,73,78,70,79,0,65,82,95,76,79,71,95,76,69,86,69,76,95,87,65,82,78,0,65,82,95,76,79,71,95,76,69,86,69,76,95,69,82,82,79,82,0,65,82,95,76,79,71,95,76,69,86,69,76,95,82,69,76,95,73,78,70,79,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,51,120,51,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,51,120,51,95,72,65,77,77,73,78,71,54,51,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,51,120,51,95,80,65,82,73,84,89,54,53,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,52,120,52,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,52,120,52,95,66,67,72,95,49,51,95,57,95,51,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,52,120,52,95,66,67,72,95,49,51,95,53,95,53,0,65,82,95,76,65,66,69,76,73,78,71,95,84,72,82,69,83,72,95,77,79,68,69,95,77,65,78,85,65,76,0,65,82,95,76,65,66,69,76,73,78,71,95,84,72,82,69,83,72,95,77,79,68,69,95,65,85,84,79,95,77,69,68,73,65,78,0,65,82,95,76,65],"i8",ALLOC_NONE,Runtime.GLOBAL_BASE); +var THREEx=THREEx||{};THREEx.ArBaseControls=function(object3d){this.id=THREEx.ArBaseControls.id++;this.object3d=object3d;this.object3d.matrixAutoUpdate=false;this.object3d.visible=false};THREEx.ArBaseControls.id=0;Object.assign(THREEx.ArBaseControls.prototype,THREE.EventDispatcher.prototype);THREEx.ArBaseControls.prototype.update=function(){console.assert(false,"you need to implement your own update")};THREEx.ArBaseControls.prototype.name=function(){console.assert(false,"you need to implement your own .name()");return"Not yet implemented - name()"};var THREEx=THREEx||{};THREEx.ARClickability=function(sourceElement){this._sourceElement=sourceElement;var fullWidth=parseInt(sourceElement.style.width);var fullHeight=parseInt(sourceElement.style.height);this._cameraPicking=new THREE.PerspectiveCamera(42,fullWidth/fullHeight,.1,100);console.warn("THREEx.ARClickability works only in modelViewMatrix")};THREEx.ARClickability.prototype.onResize=function(){var sourceElement=this._sourceElement;var cameraPicking=this._cameraPicking;var fullWidth=parseInt(sourceElement.style.width);var fullHeight=parseInt(sourceElement.style.height);cameraPicking.aspect=fullWidth/fullHeight;cameraPicking.updateProjectionMatrix()};THREEx.ARClickability.prototype.computeIntersects=function(domEvent,objects){var sourceElement=this._sourceElement;var cameraPicking=this._cameraPicking;var eventCoords=new THREE.Vector3;eventCoords.x=domEvent.layerX/parseInt(sourceElement.style.width)*2-1;eventCoords.y=-(domEvent.layerY/parseInt(sourceElement.style.height))*2+1;var raycaster=new THREE.Raycaster;raycaster.setFromCamera(eventCoords,cameraPicking);var intersects=raycaster.intersectObjects(objects);return intersects};THREEx.ARClickability.prototype.update=function(){};THREEx.ARClickability.tangoPickingPointCloud=function(artoolkitContext,mouseX,mouseY){var vrDisplay=artoolkitContext._tangoContext.vrDisplay;if(vrDisplay===null)return null;var pointAndPlane=vrDisplay.getPickingPointAndPlaneInPointCloud(mouseX,mouseY);if(pointAndPlane==null){console.warn("Could not retrieve the correct point and plane.");return null}var boundingSphereRadius=.01;var object3d=new THREE.Object3D;THREE.WebAR.positionAndRotateObject3DWithPickingPointAndPlaneInPointCloud(pointAndPlane,object3d,boundingSphereRadius);object3d.rotateZ(-Math.PI/2);var result={};result.position=object3d.position;result.quaternion=object3d.quaternion;return result};var THREEx=THREEx||{};THREEx.ArMarkerCloak=function(videoTexture){var updateInShaderEnabled=true;var geometry=new THREE.PlaneGeometry(1.3+.25,1.85+.25,1,8).translate(0,-.3,0);var material=new THREE.ShaderMaterial({vertexShader:THREEx.ArMarkerCloak.vertexShader,fragmentShader:THREEx.ArMarkerCloak.fragmentShader,transparent:true,uniforms:{texture:{value:videoTexture},opacity:{value:.5}},defines:{updateInShaderEnabled:updateInShaderEnabled?1:0}});var cloakMesh=new THREE.Mesh(geometry,material);cloakMesh.rotation.x=-Math.PI/2;this.object3d=cloakMesh;var xMin=-.65;var xMax=.65;var yMin=.65+.1;var yMax=.95+.1;var originalsFaceVertexUvs=[[]];for(var faceIndex=0;faceIndex=this.parameters.minVisibleDelay){object3d.visible=true;snapDirectlyToTarget()}}if(wasVisible===true&&targetObject3d.visible===false){var unvisibleFor=present-this._unvisibleStartedAt;if(unvisibleFor>=this.parameters.minUnvisibleDelay){object3d.visible=false}}if(this._lastLerpStepAt===null){applyOneSlerpStep();this._lastLerpStepAt=present}else{var nStepsToDo=Math.floor((present-this._lastLerpStepAt)/this.parameters.lerpStepDelay);for(var i=0;iwebvr.info for more info.")}else{alert("Your browser does not support WebVR. See webvr.info for assistance.")}this._tangoContext={vrDisplay:null,vrPointCloud:null,frameData:new VRFrameData};navigator.getVRDisplays().then(function(vrDisplays){if(vrDisplays.length===0)alert("no vrDisplays available");var vrDisplay=_this._tangoContext.vrDisplay=vrDisplays[0];console.log("vrDisplays.displayName :",vrDisplay.displayName);if(vrDisplay.displayName==="Tango VR Device"){_this._tangoContext.vrPointCloud=new THREE.WebAR.VRPointCloud(vrDisplay,true)}onCompleted()})};ARjs.Context.prototype._updateTango=function(srcElement){var _this=this;var arMarkersControls=this._arMarkersControls;var tangoContext=this._tangoContext;var vrDisplay=this._tangoContext.vrDisplay;if(vrDisplay===null)return;if(vrDisplay.displayName==="Tango VR Device"){var showPointCloud=true;var pointsToSkip=0;_this._tangoContext.vrPointCloud.update(showPointCloud,pointsToSkip,true)}if(this._arMarkersControls.length===0)return;var foundControls=this._arMarkersControls[0];var frameData=this._tangoContext.frameData;vrDisplay.getFrameData(frameData);if(frameData.pose.position===null)return;if(frameData.pose.orientation===null)return;var position=(new THREE.Vector3).fromArray(frameData.pose.position);var quaternion=(new THREE.Quaternion).fromArray(frameData.pose.orientation);var scale=new THREE.Vector3(1,1,1);var cameraTransformMatrix=(new THREE.Matrix4).compose(position,quaternion,scale);var modelViewMatrix=new THREE.Matrix4;modelViewMatrix.getInverse(cameraTransformMatrix);foundControls.updateWithModelViewMatrix(modelViewMatrix)};var ARjs=ARjs||{};var THREEx=THREEx||{};ARjs.Profile=THREEx.ArToolkitProfile=function(){this.reset();this.performance("default")};ARjs.Profile.prototype._guessPerformanceLabel=function(){var isMobile=navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i)?true:false;if(isMobile===true){return"phone-normal"}return"desktop-normal"};ARjs.Profile.prototype.reset=function(){this.sourceParameters={sourceType:"webcam"};this.contextParameters={cameraParametersUrl:THREEx.ArToolkitContext.baseURL+"../data/data/camera_para.dat",detectionMode:"mono"};this.defaultMarkerParameters={type:"pattern",patternUrl:THREEx.ArToolkitContext.baseURL+"../data/data/patt.hiro",changeMatrixMode:"modelViewMatrix"};return this};ARjs.Profile.prototype.performance=function(label){if(label==="default"){label=this._guessPerformanceLabel()}if(label==="desktop-fast"){this.contextParameters.canvasWidth=640*3;this.contextParameters.canvasHeight=480*3;this.contextParameters.maxDetectionRate=30}else if(label==="desktop-normal"){this.contextParameters.canvasWidth=640;this.contextParameters.canvasHeight=480;this.contextParameters.maxDetectionRate=60}else if(label==="phone-normal"){this.contextParameters.canvasWidth=80*4;this.contextParameters.canvasHeight=60*4;this.contextParameters.maxDetectionRate=30}else if(label==="phone-slow"){this.contextParameters.canvasWidth=80*3;this.contextParameters.canvasHeight=60*3;this.contextParameters.maxDetectionRate=30}else{console.assert(false,"unknonwn label "+label)}return this};ARjs.Profile.prototype.defaultMarker=function(trackingBackend){trackingBackend=trackingBackend||this.contextParameters.trackingBackend;if(trackingBackend==="artoolkit"){this.contextParameters.detectionMode="mono";this.defaultMarkerParameters.type="pattern";this.defaultMarkerParameters.patternUrl=THREEx.ArToolkitContext.baseURL+"../data/data/patt.hiro"}else if(trackingBackend==="aruco"){this.contextParameters.detectionMode="mono";this.defaultMarkerParameters.type="barcode";this.defaultMarkerParameters.barcodeValue=1001}else if(trackingBackend==="tango"){this.defaultMarkerParameters.type="barcode";this.defaultMarkerParameters.barcodeValue=1001}else console.assert(false);return this};ARjs.Profile.prototype.sourceWebcam=function(){this.sourceParameters.sourceType="webcam";delete this.sourceParameters.sourceUrl;return this};ARjs.Profile.prototype.sourceVideo=function(url){this.sourceParameters.sourceType="video";this.sourceParameters.sourceUrl=url;return this};ARjs.Profile.prototype.sourceImage=function(url){this.sourceParameters.sourceType="image";this.sourceParameters.sourceUrl=url;return this};ARjs.Profile.prototype.trackingBackend=function(trackingBackend){console.warn("stop profile.trackingBackend() obsolete function. use .trackingMethod instead");this.contextParameters.trackingBackend=trackingBackend;return this};ARjs.Profile.prototype.changeMatrixMode=function(changeMatrixMode){this.defaultMarkerParameters.changeMatrixMode=changeMatrixMode;return this};ARjs.Profile.prototype.trackingMethod=function(trackingMethod){var data=ARjs.Utils.parseTrackingMethod(trackingMethod);this.defaultMarkerParameters.markersAreaEnabled=data.markersAreaEnabled;this.contextParameters.trackingBackend=data.trackingBackend;return this};ARjs.Profile.prototype.checkIfValid=function(){if(this.contextParameters.trackingBackend==="tango"){this.sourceImage(THREEx.ArToolkitContext.baseURL+"../data/images/img.jpg")}return this};var ARjs=ARjs||{};var THREEx=THREEx||{};ARjs.Source=THREEx.ArToolkitSource=function(parameters){var _this=this;this.ready=false;this.domElement=null;this.parameters={sourceType:"webcam",sourceUrl:null,sourceWidth:640,sourceHeight:480,displayWidth:640,displayHeight:480};setParameters(parameters);function setParameters(parameters){if(parameters===undefined)return;for(var key in parameters){var newValue=parameters[key];if(newValue===undefined){console.warn("THREEx.ArToolkitSource: '"+key+"' parameter is undefined.");continue}var currentValue=_this.parameters[key];if(currentValue===undefined){console.warn("THREEx.ArToolkitSource: '"+key+"' is not a property of this material.");continue}_this.parameters[key]=newValue}}};ARjs.Source.prototype.init=function(onReady,onError){var _this=this;if(this.parameters.sourceType==="image"){var domElement=this._initSourceImage(onSourceReady,onError)}else if(this.parameters.sourceType==="video"){var domElement=this._initSourceVideo(onSourceReady,onError)}else if(this.parameters.sourceType==="webcam"){var domElement=this._initSourceWebcam(onSourceReady,onError)}else{console.assert(false)}this.domElement=domElement;this.domElement.style.position="absolute";this.domElement.style.top="0px";this.domElement.style.left="0px";this.domElement.style.zIndex="-2";return this;function onSourceReady(){document.body.appendChild(_this.domElement);_this.ready=true;onReady&&onReady()}};ARjs.Source.prototype._initSourceImage=function(onReady){var domElement=document.createElement("img");domElement.src=this.parameters.sourceUrl;domElement.width=this.parameters.sourceWidth;domElement.height=this.parameters.sourceHeight;domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";var interval=setInterval(function(){if(!domElement.naturalWidth)return;onReady();clearInterval(interval)},1e3/50);return domElement};ARjs.Source.prototype._initSourceVideo=function(onReady){var domElement=document.createElement("video"); +domElement.src=this.parameters.sourceUrl;domElement.style.objectFit="initial";domElement.autoplay=true;domElement.webkitPlaysinline=true;domElement.controls=false;domElement.loop=true;domElement.muted=true;document.body.addEventListener("click",function onClick(){document.body.removeEventListener("click",onClick);domElement.play()});domElement.width=this.parameters.sourceWidth;domElement.height=this.parameters.sourceHeight;domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";var interval=setInterval(function(){if(!domElement.videoWidth)return;onReady();clearInterval(interval)},1e3/50);return domElement};ARjs.Source.prototype._initSourceWebcam=function(onReady,onError){var _this=this;onError=onError||function(error){alert("Webcam Error\nName: "+error.name+"\nMessage: "+error.message)};var domElement=document.createElement("video");domElement.setAttribute("autoplay","");domElement.setAttribute("muted","");domElement.setAttribute("playsinline","");domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";if(navigator.mediaDevices===undefined||navigator.mediaDevices.enumerateDevices===undefined||navigator.mediaDevices.getUserMedia===undefined){onError({name:"",message:"WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser"});return}navigator.mediaDevices.enumerateDevices().then(function(devices){var userMediaConstraints={audio:false,video:{facingMode:"environment",width:{ideal:_this.parameters.sourceWidth},height:{ideal:_this.parameters.sourceHeight}}};navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream){domElement.srcObject=stream;document.body.addEventListener("click",function(){domElement.play()});var interval=setInterval(function(){if(!domElement.videoWidth)return;onReady();clearInterval(interval)},1e3/50)}).catch(function(error){onError({name:error.name,message:error.message})})}).catch(function(error){onError({message:error.message})});return domElement};ARjs.Source.prototype.hasMobileTorch=function(){var stream=arToolkitSource.domElement.srcObject;if(stream instanceof MediaStream===false)return false;if(this._currentTorchStatus===undefined){this._currentTorchStatus=false}var videoTrack=stream.getVideoTracks()[0];if(videoTrack.getCapabilities===undefined)return false;var capabilities=videoTrack.getCapabilities();return capabilities.torch?true:false};ARjs.Source.prototype.toggleMobileTorch=function(){console.assert(this.hasMobileTorch()===true);var stream=arToolkitSource.domElement.srcObject;if(stream instanceof MediaStream===false){alert("enabling mobile torch is available only on webcam");return}if(this._currentTorchStatus===undefined){this._currentTorchStatus=false}var videoTrack=stream.getVideoTracks()[0];var capabilities=videoTrack.getCapabilities();if(!capabilities.torch){alert("no mobile torch is available on your camera");return}this._currentTorchStatus=this._currentTorchStatus===false?true:false;videoTrack.applyConstraints({advanced:[{torch:this._currentTorchStatus}]}).catch(function(error){console.log(error)})};ARjs.Source.prototype.onResizeElement=function(mirrorDomElements){var _this=this;var screenWidth=window.innerWidth;var screenHeight=window.innerHeight;if(this.domElement.nodeName==="IMG"){var sourceWidth=this.domElement.naturalWidth;var sourceHeight=this.domElement.naturalHeight}else if(this.domElement.nodeName==="VIDEO"){var sourceWidth=this.domElement.videoWidth;var sourceHeight=this.domElement.videoHeight}else{console.assert(false)}var sourceAspect=sourceWidth/sourceHeight;var screenAspect=screenWidth/screenHeight;if(screenAspect3)console.assert("wrong api for",THREEx.ArMultiMarkerControls);this.parameters={subMarkersControls:parameters.subMarkersControls,subMarkerPoses:parameters.subMarkerPoses,changeMatrixMode:parameters.changeMatrixMode!==undefined?parameters.changeMatrixMode:"modelViewMatrix"};this.object3d.visible=false;this.subMarkersControls=this.parameters.subMarkersControls;this.subMarkerPoses=this.parameters.subMarkerPoses;arToolkitContext.addEventListener("sourceProcessed",function(){_this._onSourceProcessed()})};THREEx.ArMultiMarkerControls.prototype=Object.create(THREEx.ArBaseControls.prototype);THREEx.ArMultiMarkerControls.prototype.constructor=THREEx.ArMultiMarkerControls;THREEx.ArMultiMarkerControls.prototype._onSourceProcessed=function(){var _this=this;var stats={count:0,position:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)},quaternion:{sum:new THREE.Quaternion(0,0,0,0),average:new THREE.Quaternion(0,0,0,0)},scale:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)}};var firstQuaternion=_this.parameters.subMarkersControls[0].object3d.quaternion;this.parameters.subMarkersControls.forEach(function(markerControls,markerIndex){var markerObject3d=markerControls.object3d;if(markerObject3d.visible===false)return;var matrix=markerObject3d.matrix.clone();var markerPose=_this.parameters.subMarkerPoses[markerIndex];matrix.multiply((new THREE.Matrix4).getInverse(markerPose));var position=new THREE.Vector3;var quaternion=new THREE.Quaternion;var scale=new THREE.Vector3;matrix.decompose(position,quaternion,scale);stats.count++;THREEx.ArMultiMarkerControls.averageVector3(stats.position.sum,position,stats.count,stats.position.average);THREEx.ArMultiMarkerControls.averageQuaternion(stats.quaternion.sum,quaternion,firstQuaternion,stats.count,stats.quaternion.average);THREEx.ArMultiMarkerControls.averageVector3(stats.scale.sum,scale,stats.count,stats.scale.average)});if(stats.count>0){_this.object3d.visible=true}else{_this.object3d.visible=false}if(stats.count>0){var modelViewMatrix=new THREE.Matrix4;modelViewMatrix.compose(stats.position.average,stats.quaternion.average,stats.scale.average);if(this.parameters.changeMatrixMode==="modelViewMatrix"){_this.object3d.matrix.copy(modelViewMatrix)}else if(this.parameters.changeMatrixMode==="cameraTransformMatrix"){_this.object3d.matrix.getInverse(modelViewMatrix)}else{console.assert(false)}_this.object3d.matrix.decompose(_this.object3d.position,_this.object3d.quaternion,_this.object3d.scale)}};THREEx.ArMultiMarkerControls.averageQuaternion=function(quaternionSum,newQuaternion,firstQuaternion,count,quaternionAverage){quaternionAverage=quaternionAverage||new THREE.Quaternion;console.assert(firstQuaternion instanceof THREE.Quaternion===true);if(newQuaternion.dot(firstQuaternion)>0){newQuaternion=new THREE.Quaternion(-newQuaternion.x,-newQuaternion.y,-newQuaternion.z,-newQuaternion.w)}quaternionSum.x+=newQuaternion.x;quaternionSum.y+=newQuaternion.y;quaternionSum.z+=newQuaternion.z;quaternionSum.w+=newQuaternion.w;quaternionAverage.x=quaternionSum.x/count;quaternionAverage.y=quaternionSum.y/count;quaternionAverage.z=quaternionSum.z/count;quaternionAverage.w=quaternionSum.w/count;quaternionAverage.normalize();return quaternionAverage};THREEx.ArMultiMarkerControls.averageVector3=function(vector3Sum,vector3,count,vector3Average){vector3Average=vector3Average||new THREE.Vector3;vector3Sum.x+=vector3.x;vector3Sum.y+=vector3.y;vector3Sum.z+=vector3.z;vector3Average.x=vector3Sum.x/count;vector3Average.y=vector3Sum.y/count;vector3Average.z=vector3Sum.z/count;return vector3Average};THREEx.ArMultiMarkerControls.computeCenter=function(jsonData){var multiMarkerFile=JSON.parse(jsonData);var stats={count:0,position:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)},quaternion:{sum:new THREE.Quaternion(0,0,0,0),average:new THREE.Quaternion(0,0,0,0)},scale:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)}};var firstQuaternion=new THREE.Quaternion;multiMarkerFile.subMarkersControls.forEach(function(item){var poseMatrix=(new THREE.Matrix4).fromArray(item.poseMatrix);var position=new THREE.Vector3;var quaternion=new THREE.Quaternion;var scale=new THREE.Vector3;poseMatrix.decompose(position,quaternion,scale);stats.count++;THREEx.ArMultiMarkerControls.averageVector3(stats.position.sum,position,stats.count,stats.position.average);THREEx.ArMultiMarkerControls.averageQuaternion(stats.quaternion.sum,quaternion,firstQuaternion,stats.count,stats.quaternion.average);THREEx.ArMultiMarkerControls.averageVector3(stats.scale.sum,scale,stats.count,stats.scale.average)});var averageMatrix=new THREE.Matrix4;averageMatrix.compose(stats.position.average,stats.quaternion.average,stats.scale.average);return averageMatrix};THREEx.ArMultiMarkerControls.computeBoundingBox=function(jsonData){var multiMarkerFile=JSON.parse(jsonData);var boundingBox=new THREE.Box3;multiMarkerFile.subMarkersControls.forEach(function(item){var poseMatrix=(new THREE.Matrix4).fromArray(item.poseMatrix);var position=new THREE.Vector3;var quaternion=new THREE.Quaternion;var scale=new THREE.Vector3;poseMatrix.decompose(position,quaternion,scale);boundingBox.expandByPoint(position)});return boundingBox};THREEx.ArMultiMarkerControls.prototype.updateSmoothedControls=function(smoothedControls,lerpsValues){if(lerpsValues===undefined){lerpsValues=[[.1,.1,.3],[.2,.1,.4],[.2,.2,.5],[.3,.2,.7],[.3,.2,.7]]}var nVisible=0;this.parameters.subMarkersControls.forEach(function(markerControls,markerIndex){var markerObject3d=markerControls.object3d;if(markerObject3d.visible===true)nVisible++});if(lerpsValues[nVisible-1]!==undefined){var lerpValues=lerpsValues[nVisible-1]}else{var lerpValues=lerpsValues[lerpsValues.length-1]}smoothedControls.parameters.lerpPosition=lerpValues[0];smoothedControls.parameters.lerpQuaternion=lerpValues[1];smoothedControls.parameters.lerpScale=lerpValues[2]};THREEx.ArMultiMarkerControls.fromJSON=function(arToolkitContext,parent3D,markerRoot,jsonData,parameters){var multiMarkerFile=JSON.parse(jsonData);var subMarkersControls=[];var subMarkerPoses=[];parameters=parameters||{};multiMarkerFile.subMarkersControls.forEach(function(item){var markerRoot=new THREE.Object3D;parent3D.add(markerRoot);var subMarkerControls=new THREEx.ArMarkerControls(arToolkitContext,markerRoot,item.parameters);subMarkersControls.push(subMarkerControls);subMarkerPoses.push((new THREE.Matrix4).fromArray(item.poseMatrix))});parameters.subMarkersControls=subMarkersControls;parameters.subMarkerPoses=subMarkerPoses;var multiMarkerControls=new THREEx.ArMultiMarkerControls(arToolkitContext,markerRoot,parameters);return multiMarkerControls};var THREEx=THREEx||{};THREEx.ArMultiMakersLearning=function(arToolkitContext,subMarkersControls){var _this=this;this._arToolkitContext=arToolkitContext;this.subMarkersControls=subMarkersControls;this.enabled=true;arToolkitContext.addEventListener("sourceProcessed",function(){_this._onSourceProcessed()})};THREEx.ArMultiMakersLearning.prototype._onSourceProcessed=function(){var originQuaternion=this.subMarkersControls[0].object3d.quaternion;if(this.enabled===false)return;var visibleMarkerControls=this.subMarkersControls.filter(function(markerControls){return markerControls.object3d.visible===true});var count=Object.keys(visibleMarkerControls).length;var positionDelta=new THREE.Vector3;var quaternionDelta=new THREE.Quaternion;var scaleDelta=new THREE.Vector3;var tmpMatrix=new THREE.Matrix4;for(var i=0;i=1?true:false;if(isLearned===true)return;var otherSubControlsID=_this._getLearnedCoupleStats(subMarkerControls);if(otherSubControlsID===null){return}var otherSubControls=_this._getSubMarkerControlsByID(otherSubControlsID);var seenCoupleStats=subMarkerControls.object3d.userData.seenCouples[otherSubControlsID];var averageMatrix=new THREE.Matrix4;averageMatrix.compose(seenCoupleStats.position.average,seenCoupleStats.quaternion.average,seenCoupleStats.scale.average);var otherAverageMatrix=otherSubControls.object3d.userData.result.averageMatrix;var matrix=(new THREE.Matrix4).getInverse(otherAverageMatrix).multiply(averageMatrix);matrix=(new THREE.Matrix4).getInverse(matrix);console.assert(subMarkerControls.object3d.userData.result===undefined);subMarkerControls.object3d.userData.result={averageMatrix:matrix,confidenceFactor:1};resultChanged=true})}while(resultChanged===true)};THREEx.ArMultiMakersLearning.prototype._getLearnedCoupleStats=function(subMarkerControls){if(subMarkerControls.object3d.userData.seenCouples===undefined)return null;var seenCouples=subMarkerControls.object3d.userData.seenCouples;var coupleControlsIDs=Object.keys(seenCouples).map(Number);for(var i=0;i=1?true:false;if(isLearned===false)continue;return otherSubControlsID}return null};THREEx.ArMultiMakersLearning.prototype._getSubMarkerControlsByID=function(controlsID){for(var i=0;i0){var newPosition=this._pickingPlane.worldToLocal(intersects[0].point.clone());var scale=new THREE.Vector3(1,1,1).multiplyScalar(1);var hitTestResult=new ARjs.HitTester.Result(newPosition,new THREE.Quaternion,scale);hitTestResults.push(hitTestResult)}}return hitTestResults};ARjs.HitTester.Result=function(position,quaternion,scale){this.position=position;this.quaternion=quaternion;this.scale=scale};var ARjs=ARjs||{};ARjs.Session=function(parameters){var _this=this;this.renderer=parameters.renderer;this.camera=parameters.camera;this.scene=parameters.scene;console.log("AR.js",THREEx.ArToolkitContext.REVISION,"- trackingBackend:",parameters.contextParameters.trackingBackend);var arSource=_this.arSource=new THREEx.ArToolkitSource(parameters.sourceParameters);arSource.init(function onReady(){arSource.onResize(arContext,_this.renderer,_this.camera)});window.addEventListener("resize",function(){arSource.onResize(arContext,_this.renderer,_this.camera)});var arContext=_this.arContext=new THREEx.ArToolkitContext(parameters.contextParameters);_this.arContext.init();arContext.addEventListener("initialized",function(event){arSource.onResize(arContext,_this.renderer,_this.camera)});this.update=function(){if(arSource.ready===false)return;arContext.update(arSource.domElement)}};ARjs.Session.prototype.onResize=function(){this.arSource.onResize(this.arContext,this.renderer,this.camera)};var ARjs=ARjs||{};ARjs.TangoPointCloud=function(arSession){var _this=this;var arContext=arSession.arContext;this.object3d=new THREE.Group;console.warn("Work only on cameraTransformMatrix - fix me - useless limitation");arContext.addEventListener("initialized",function(event){var vrPointCloud=arContext._tangoContext.vrPointCloud;var geometry=vrPointCloud.getBufferGeometry();var material=new THREE.PointsMaterial({size:.01,depthWrite:false});var pointsObject=new THREE.Points(geometry,material);pointsObject.frustumCulled=false;pointsObject.renderDepth=0;_this.object3d.add(pointsObject)})};var ARjs=ARjs||{};ARjs.TangoVideoMesh=function(arSession){var arContext=arSession.arContext;var renderer=arSession.renderer;var videoMesh=null;var vrDisplay=null;var sceneOrtho=new THREE.Scene;var cameraOrtho=new THREE.OrthographicCamera(-1,1,1,-1,0,100);this._sceneOrtho=sceneOrtho;this._cameraOrtho=cameraOrtho;arContext.addEventListener("initialized",function(event){console.assert(arContext.parameters.trackingBackend==="tango");vrDisplay=arContext._tangoContext.vrDisplay;console.assert(vrDisplay,"vrDisplay MUST be defined");if(vrDisplay.displayName!=="Tango VR Device")return;videoMesh=THREE.WebAR.createVRSeeThroughCameraMesh(vrDisplay);sceneOrtho.add(videoMesh)});this.update=function(){console.assert(arContext.parameters.trackingBackend==="tango");if(videoMesh===null)return;THREE.WebAR.updateCameraMeshOrientation(vrDisplay,videoMesh)};this.render=function(){console.assert(arContext.parameters.trackingBackend==="tango");renderer.render(sceneOrtho,cameraOrtho);renderer.clearDepth()}};AFRAME.registerSystem("arjs",{schema:{trackingBackend:{type:"string","default":"artoolkit"},areaLearningButton:{type:"boolean","default":true},performanceProfile:{type:"string","default":"default"},debug:{type:"boolean","default":false},detectionMode:{type:"string","default":""},matrixCodeType:{type:"string","default":""},cameraParametersUrl:{type:"string","default":""},maxDetectionRate:{type:"number","default":-1},sourceType:{type:"string","default":""},sourceUrl:{type:"string","default":""},sourceWidth:{type:"number", +"default":-1},sourceHeight:{type:"number","default":-1},displayWidth:{type:"number","default":-1},displayHeight:{type:"number","default":-1},canvasWidth:{type:"number","default":-1},canvasHeight:{type:"number","default":-1}},init:function(){var _this=this;var artoolkitProfile=new THREEx.ArToolkitProfile;artoolkitProfile.sourceWebcam();artoolkitProfile.trackingBackend(this.data.trackingBackend);artoolkitProfile.performance(this.data.performanceProfile);if(this.data.debug!==false)artoolkitProfile.contextParameters.debug=this.data.debug;if(this.data.detectionMode!=="")artoolkitProfile.contextParameters.detectionMode=this.data.detectionMode;if(this.data.matrixCodeType!=="")artoolkitProfile.contextParameters.matrixCodeType=this.data.matrixCodeType;if(this.data.cameraParametersUrl!=="")artoolkitProfile.contextParameters.cameraParametersUrl=this.data.cameraParametersUrl;if(this.data.maxDetectionRate!==-1)artoolkitProfile.contextParameters.maxDetectionRate=this.data.maxDetectionRate;if(this.data.sourceType!=="")artoolkitProfile.contextParameters.sourceType=this.data.sourceType;if(this.data.sourceUrl!=="")artoolkitProfile.contextParameters.sourceUrl=this.data.sourceUrl;if(this.data.sourceWidth!==-1)artoolkitProfile.contextParameters.sourceWidth=this.data.sourceWidth;if(this.data.sourceHeight!==-1)artoolkitProfile.contextParameters.sourceHeight=this.data.sourceHeight;if(this.data.displayWidth!==-1)artoolkitProfile.contextParameters.displayWidth=this.data.displayWidth;if(this.data.displayHeight!==-1)artoolkitProfile.contextParameters.displayHeight=this.data.displayHeight;if(this.data.canvasWidth!==-1)artoolkitProfile.contextParameters.canvasWidth=this.data.canvasWidth;if(this.data.canvasHeight!==-1)artoolkitProfile.contextParameters.canvasHeight=this.data.canvasHeight;var arToolkitSource=new THREEx.ArToolkitSource(artoolkitProfile.sourceParameters);this.arToolkitSource=arToolkitSource;arToolkitSource.init(function onReady(){onResize();var startedAt=Date.now();var timerId=setInterval(function(){if(Date.now()-startedAt>10*1e3){clearInterval(timerId);return}window.dispatchEvent(new Event("resize"))},1e3/30)});window.addEventListener("resize",onResize);function onResize(){arToolkitSource.onResizeElement();arToolkitSource.copyElementSizeTo(document.body);var buttonElement=document.querySelector(".a-enter-vr");if(buttonElement){buttonElement.style.position="fixed"}}var arToolkitContext=new THREEx.ArToolkitContext(artoolkitProfile.contextParameters);this.arToolkitContext=arToolkitContext;arToolkitContext.init(function onCompleted(){});this.navigateToLearnerPage=function(){var learnerURL=THREEx.ArToolkitContext.baseURL+"examples/multi-markers/examples/learner.html";THREEx.ArMultiMarkerUtils.navigateToLearnerPage(learnerURL,_this.data.trackingBackend)};this.initAreaLearningButton=function(){if(this.data.areaLearningButton===false)return;if(document.querySelector("#arjsAreaLearningButton")!==null)return;var imgElement=document.createElement("img");imgElement.id="arjsAreaLearningButton";imgElement.style.position="fixed";imgElement.style.bottom="16px";imgElement.style.left="16px";imgElement.style.width="48px";imgElement.style.height="48px";imgElement.style.zIndex=1;imgElement.src=THREEx.ArToolkitContext.baseURL+"examples/multi-markers/examples/images/record-start.png";document.body.appendChild(imgElement);imgElement.addEventListener("click",function(){_this.navigateToLearnerPage()})}},tick:function(now,delta){if(this.arToolkitSource.ready===false)return;if(this.arToolkitContext.arController!==null){this.el.sceneEl.camera.projectionMatrix.copy(this.arToolkitContext.getProjectionMatrix())}this.arToolkitContext.update(this.arToolkitSource.domElement)}});AFRAME.registerComponent("arjsmarker",{dependencies:["arjs","artoolkit"],schema:{preset:{type:"string"},markerhelpers:{type:"boolean","default":false},size:{type:"number","default":1},type:{type:"string"},patternUrl:{type:"string"},barcodeValue:{type:"number"},changeMatrixMode:{type:"string","default":"modelViewMatrix"},minConfidence:{type:"number","default":.6}},init:function(){var _this=this;var arjsSystem=this.el.sceneEl.systems.arjs||this.el.sceneEl.systems.artoolkit;var artoolkitContext=arjsSystem.arToolkitContext;var scene=this.el.sceneEl.object3D;if(this.data.preset==="hiro"){this.data.type="pattern";this.data.patternUrl=THREEx.ArToolkitContext.baseURL+"examples/marker-training/examples/pattern-files/pattern-hiro.patt"}else if(this.data.preset==="kanji"){this.data.type="pattern";this.data.patternUrl=THREEx.ArToolkitContext.baseURL+"examples/marker-training/examples/pattern-files/pattern-kanji.patt"}else if(this.data.preset==="area"){this.data.type="area"}else{console.assert(this.data.preset==="","illegal preset value "+this.data.preset)}this._markerRoot=new THREE.Group;scene.add(this._markerRoot);this._arMarkerControls=null;this._multiMarkerControls=null;if(this.data.type==="area"){if(localStorage.getItem("ARjsMultiMarkerFile")===null){THREEx.ArMultiMarkerUtils.storeDefaultMultiMarkerFile(arjsSystem.data.trackingBackend)}console.assert(localStorage.getItem("ARjsMultiMarkerFile")!==null);var multiMarkerFile=localStorage.getItem("ARjsMultiMarkerFile");this._multiMarkerControls=THREEx.ArMultiMarkerControls.fromJSON(artoolkitContext,scene,this._markerRoot,multiMarkerFile,{changeMatrixMode:this.data.changeMatrixMode});console.log("this.data.markerhelpers",this.data.markerhelpers);if(this.data.markerhelpers===true){this._multiMarkerControls.subMarkersControls.forEach(function(subMarkerControls){var markerHelper=new THREEx.ArMarkerHelper(subMarkerControls);scene.add(markerHelper.object3d)})}}else if(this.data.type==="pattern"||this.data.type==="barcode"||this.data.type==="unknown"){this._arMarkerControls=new THREEx.ArMarkerControls(artoolkitContext,this._markerRoot,this.data)}else console.assert(false);this.arSmoothedControls=new THREEx.ArSmoothedControls(this.el.object3D,{lerpPosition:.1,lerpQuaternion:.1,lerpScale:.1});if(this.data.type==="area")arjsSystem.initAreaLearningButton()},remove:function(){},update:function(){},tick:function(){if(this.data.changeMatrixMode==="cameraTransformMatrix"){this.el.sceneEl.object3D.visible=this.el.object3D.visible}if(this._multiMarkerControls!==null){this._multiMarkerControls.updateSmoothedControls(this.arSmoothedControls)}this.arSmoothedControls.update(this._markerRoot)}});AFRAME.registerPrimitive("a-marker",AFRAME.utils.extendDeep({},AFRAME.primitives.getMeshMixin(),{defaultComponents:{arjsmarker:{}},mappings:{type:"arjsmarker.type",size:"arjsmarker.size",url:"arjsmarker.patternUrl",value:"arjsmarker.barcodeValue",preset:"arjsmarker.preset",minConfidence:"arjsmarker.minConfidence",markerhelpers:"arjsmarker.markerhelpers"}}));AFRAME.registerPrimitive("a-marker-camera",AFRAME.utils.extendDeep({},AFRAME.primitives.getMeshMixin(),{defaultComponents:{arjsmarker:{changeMatrixMode:"cameraTransformMatrix"},camera:true},mappings:{type:"arjsmarker.type",size:"arjsmarker.size",url:"arjsmarker.patternUrl",value:"arjsmarker.barcodeValue",preset:"arjsmarker.preset",minConfidence:"arjsmarker.minConfidence",markerhelpers:"arjsmarker.markerhelpers"}}));(function(){"use strict";var ARController=function(width,height,camera){var id;var w=width,h=height;this.orientation="landscape";this.listeners={};if(typeof width!=="number"){var image=width;camera=height;w=image.videoWidth||image.width;h=image.videoHeight||image.height;this.image=image}this.defaultMarkerWidth=1;this.patternMarkers={};this.barcodeMarkers={};this.transform_mat=new Float32Array(16);this.canvas=document.createElement("canvas");this.canvas.width=w;this.canvas.height=h;this.ctx=this.canvas.getContext("2d");this.videoWidth=w;this.videoHeight=h;if(typeof camera==="string"){var self=this;this.cameraParam=new ARCameraParam(camera,function(){self._initialize()},function(err){console.error("ARController: Failed to load ARCameraParam",err)})}else{this.cameraParam=camera;this._initialize()}};ARController.prototype.dispose=function(){artoolkit.teardown(this.id);for(var t in this){this[t]=null}};ARController.prototype.process=function(image){this.detectMarker(image);var markerNum=this.getMarkerNum();var k,o;for(k in this.patternMarkers){o=this.patternMarkers[k];o.inPrevious=o.inCurrent;o.inCurrent=false}for(k in this.barcodeMarkers){o=this.barcodeMarkers[k];o.inPrevious=o.inCurrent;o.inCurrent=false}for(var i=0;i-1&&(markerInfo.id===markerInfo.idPatt||markerInfo.idMatrix===-1)){visible=this.trackPatternMarkerId(markerInfo.idPatt);markerType=artoolkit.PATTERN_MARKER;if(markerInfo.dir!==markerInfo.dirPatt){this.setMarkerInfoDir(i,markerInfo.dirPatt)}}else if(markerInfo.idMatrix>-1){visible=this.trackBarcodeMarkerId(markerInfo.idMatrix);markerType=artoolkit.BARCODE_MARKER;if(markerInfo.dir!==markerInfo.dirMatrix){this.setMarkerInfoDir(i,markerInfo.dirMatrix)}}if(markerType!==artoolkit.UNKNOWN_MARKER&&visible.inPrevious){this.getTransMatSquareCont(i,visible.markerWidth,visible.matrix,visible.matrix)}else{this.getTransMatSquare(i,visible.markerWidth,visible.matrix)}visible.inCurrent=true;this.transMatToGLMat(visible.matrix,this.transform_mat);this.dispatchEvent({name:"getMarker",target:this,data:{index:i,type:markerType,marker:markerInfo,matrix:this.transform_mat}})}var multiMarkerCount=this.getMultiMarkerCount();for(var i=0;i=0){visible=true;this.dispatchEvent({name:"getMultiMarker",target:this,data:{multiMarkerId:i,matrix:this.transform_mat}});break}}if(visible){for(var j=0;j-1){this.listeners[name].splice(index,1)}}};ARController.prototype.dispatchEvent=function(event){var listeners=this.listeners[event.name];if(listeners){for(var i=0;i-1){writeStringToFS(filename,url,writeCallback)}else{ajax(url,filename,writeCallback)}}function writeStringToFS(target,string,callback){var byteArray=new Uint8Array(string.length);for(var i=0;i1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}else{Module["thisProgram"]="unknown-program"}}Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL){if(!Module["print"])Module["print"]=print;if(typeof printErr!="undefined")Module["printErr"]=printErr;if(typeof read!="undefined"){Module["read"]=read}else{Module["read"]=function read(){throw"no read() available (jsc?)"}}Module["readBinary"]=function readBinary(f){if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}var data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof console!=="undefined"){if(!Module["print"])Module["print"]=function print(x){console.log(x)};if(!Module["printErr"])Module["printErr"]=function printErr(x){console.log(x)}}else{var TRY_USE_DUMP=false;if(!Module["print"])Module["print"]=TRY_USE_DUMP&&typeof dump!=="undefined"?function(x){dump(x)}:function(x){}}if(ENVIRONMENT_IS_WORKER){Module["load"]=importScripts}if(typeof Module["setWindowTitle"]==="undefined"){Module["setWindowTitle"]=function(title){document.title=title}}}else{throw"Unknown runtime environment. Where are we?"}function globalEval(x){eval.call(null,x)}if(!Module["load"]&&Module["read"]){Module["load"]=function load(f){globalEval(Module["read"](f))}}if(!Module["print"]){Module["print"]=function(){}}if(!Module["printErr"]){Module["printErr"]=Module["print"]}if(!Module["arguments"]){Module["arguments"]=[]}if(!Module["thisProgram"]){Module["thisProgram"]="./this.program"}Module.print=Module["print"];Module.printErr=Module["printErr"];Module["preRun"]=[];Module["postRun"]=[];for(var key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}var Runtime={setTempRet0:function(value){tempRet0=value},getTempRet0:function(){return tempRet0},stackSave:function(){return STACKTOP},stackRestore:function(stackTop){STACKTOP=stackTop},getNativeTypeSize:function(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return Runtime.QUANTUM_SIZE}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}},getNativeFieldSize:function(type){return Math.max(Runtime.getNativeTypeSize(type),Runtime.QUANTUM_SIZE)},STACK_ALIGN:16,prepVararg:function(ptr,type){if(type==="double"||type==="i64"){if(ptr&7){assert((ptr&7)===4);ptr+=4}}else{assert((ptr&3)===0)}return ptr},getAlignSize:function(type,size,vararg){if(!vararg&&(type=="i64"||type=="double"))return 8;if(!type)return Math.min(size,8);return Math.min(size||(type?Runtime.getNativeFieldSize(type):0),Runtime.QUANTUM_SIZE)},dynCall:function(sig,ptr,args){if(args&&args.length){if(!args.splice)args=Array.prototype.slice.call(args); +args.splice(0,0,ptr);return Module["dynCall_"+sig].apply(null,args)}else{return Module["dynCall_"+sig].call(null,ptr)}},functionPointers:[],addFunction:function(func){for(var i=0;i=TOTAL_MEMORY){var success=enlargeMemory();if(!success){DYNAMICTOP=ret;return 0}}return ret},alignMemory:function(size,quantum){var ret=size=Math.ceil(size/(quantum?quantum:16))*(quantum?quantum:16);return ret},makeBigInt:function(low,high,unsigned){var ret=unsigned?+(low>>>0)+ +(high>>>0)*+4294967296:+(low>>>0)+ +(high|0)*+4294967296;return ret},GLOBAL_BASE:8,QUANTUM_SIZE:4,__dummy__:0};Module["Runtime"]=Runtime;var __THREW__=0;var ABORT=false;var EXITSTATUS=0;var undef=0;var tempValue,tempInt,tempBigInt,tempInt2,tempBigInt2,tempPair,tempBigIntI,tempBigIntR,tempBigIntS,tempBigIntP,tempBigIntD,tempDouble,tempFloat;var tempI64,tempI64b;var tempRet0,tempRet1,tempRet2,tempRet3,tempRet4,tempRet5,tempRet6,tempRet7,tempRet8,tempRet9;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}var globalScope=this;function getCFunc(ident){var func=Module["_"+ident];if(!func){try{func=eval("_"+ident)}catch(e){}}assert(func,"Cannot call unknown function "+ident+" (perhaps LLVM optimizations or closure removed it?)");return func}var cwrap,ccall;(function(){var JSfuncs={stackSave:function(){Runtime.stackSave()},stackRestore:function(){Runtime.stackRestore()},arrayToC:function(arr){var ret=Runtime.stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret},stringToC:function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=Runtime.stackAlloc((str.length<<2)+1);writeStringToMemory(str,ret)}return ret}};var toC={string:JSfuncs["stringToC"],array:JSfuncs["arrayToC"]};ccall=function ccallFunc(ident,returnType,argTypes,args,opts){var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=+1?tempDouble>+0?(Math_min(+Math_floor(tempDouble/+4294967296),+4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/+4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}Module["setValue"]=setValue;function getValue(ptr,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP32[ptr>>2];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];default:abort("invalid type for setValue: "+type)}return null}Module["getValue"]=getValue;var ALLOC_NORMAL=0;var ALLOC_STACK=1;var ALLOC_STATIC=2;var ALLOC_DYNAMIC=3;var ALLOC_NONE=4;Module["ALLOC_NORMAL"]=ALLOC_NORMAL;Module["ALLOC_STACK"]=ALLOC_STACK;Module["ALLOC_STATIC"]=ALLOC_STATIC;Module["ALLOC_DYNAMIC"]=ALLOC_DYNAMIC;Module["ALLOC_NONE"]=ALLOC_NONE;function allocate(slab,types,allocator,ptr){var zeroinit,size;if(typeof slab==="number"){zeroinit=true;size=slab}else{zeroinit=false;size=slab.length}var singleType=typeof types==="string"?types:null;var ret;if(allocator==ALLOC_NONE){ret=ptr}else{ret=[_malloc,Runtime.stackAlloc,Runtime.staticAlloc,Runtime.dynamicAlloc][allocator===undefined?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var ptr=ret,stop;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr>2]=0}stop=ret+size;while(ptr>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return Module["UTF8ToString"](ptr)}Module["Pointer_stringify"]=Pointer_stringify;function AsciiToString(ptr){var str="";while(1){var ch=HEAP8[ptr++>>0];if(!ch)return str;str+=String.fromCharCode(ch)}}Module["AsciiToString"]=AsciiToString;function stringToAscii(str,outPtr){return writeAsciiToMemory(str,outPtr,false)}Module["stringToAscii"]=stringToAscii;function UTF8ArrayToString(u8Array,idx){var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}Module["UTF8ArrayToString"]=UTF8ArrayToString;function UTF8ToString(ptr){return UTF8ArrayToString(HEAPU8,ptr)}Module["UTF8ToString"]=UTF8ToString;function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}Module["stringToUTF8Array"]=stringToUTF8Array;function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}Module["stringToUTF8"]=stringToUTF8;function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){++len}else if(u<=2047){len+=2}else if(u<=65535){len+=3}else if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}Module["lengthBytesUTF8"]=lengthBytesUTF8;function UTF16ToString(ptr){var i=0;var str="";while(1){var codeUnit=HEAP16[ptr+i*2>>1];if(codeUnit==0)return str;++i;str+=String.fromCharCode(codeUnit)}}Module["UTF16ToString"]=UTF16ToString;function stringToUTF16(str,outPtr,maxBytesToWrite){if(maxBytesToWrite===undefined){maxBytesToWrite=2147483647}if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite>1]=codeUnit;outPtr+=2}HEAP16[outPtr>>1]=0;return outPtr-startPtr}Module["stringToUTF16"]=stringToUTF16;function lengthBytesUTF16(str){return str.length*2}Module["lengthBytesUTF16"]=lengthBytesUTF16;function UTF32ToString(ptr){var i=0;var str="";while(1){var utf32=HEAP32[ptr+i*4>>2];if(utf32==0)return str;++i;if(utf32>=65536){var ch=utf32-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}else{str+=String.fromCharCode(utf32)}}}Module["UTF32ToString"]=UTF32ToString;function stringToUTF32(str,outPtr,maxBytesToWrite){if(maxBytesToWrite===undefined){maxBytesToWrite=2147483647}if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i=55296&&codeUnit<=57343){var trailSurrogate=str.charCodeAt(++i);codeUnit=65536+((codeUnit&1023)<<10)|trailSurrogate&1023}HEAP32[outPtr>>2]=codeUnit;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr>>2]=0;return outPtr-startPtr}Module["stringToUTF32"]=stringToUTF32;function lengthBytesUTF32(str){var len=0;for(var i=0;i=55296&&codeUnit<=57343)++i;len+=4}return len}Module["lengthBytesUTF32"]=lengthBytesUTF32;function demangle(func){var hasLibcxxabi=!!Module["___cxa_demangle"];if(hasLibcxxabi){try{var buf=_malloc(func.length);writeStringToMemory(func.substr(1),buf);var status=_malloc(4);var ret=Module["___cxa_demangle"](buf,0,0,status);if(getValue(status,"i32")===0&&ret){return Pointer_stringify(ret)}}catch(e){}finally{if(buf)_free(buf);if(status)_free(status);if(ret)_free(ret)}}var i=3;var basicTypes={v:"void",b:"bool",c:"char",s:"short",i:"int",l:"long",f:"float",d:"double",w:"wchar_t",a:"signed char",h:"unsigned char",t:"unsigned short",j:"unsigned int",m:"unsigned long",x:"long long",y:"unsigned long long",z:"..."};var subs=[];var first=true;function dump(x){if(x)Module.print(x);Module.print(func);var pre="";for(var a=0;a"}else{ret=name}paramLoop:while(i0){var c=func[i++];if(c in basicTypes){list.push(basicTypes[c])}else{switch(c){case"P":list.push(parse(true,1,true)[0]+"*");break;case"R":list.push(parse(true,1,true)[0]+"&");break;case"L":{i++;var end=func.indexOf("E",i);var size=end-i;list.push(func.substr(i,size));i+=size+2;break};case"A":{var size=parseInt(func.substr(i));i+=size.toString().length;if(func[i]!=="_")throw"?";i++;list.push(parse(true,1,true)[0]+" ["+size+"]");break};case"E":break paramLoop;default:ret+="?"+c;break paramLoop}}}if(!allowVoid&&list.length===1&&list[0]==="void")list=[];if(rawList){if(ret){list.push(ret+"?")}return list}else{return ret+flushList()}}var parsed=func;try{if(func=="Object._main"||func=="_main"){return"main()"}if(typeof func==="number")func=Pointer_stringify(func);if(func[0]!=="_")return func;if(func[1]!=="_")return func;if(func[2]!=="Z")return func;switch(func[3]){case"n":return"operator new()";case"d":return"operator delete()"}parsed=parse()}catch(e){parsed+="?"}if(parsed.indexOf("?")>=0&&!hasLibcxxabi){Runtime.warnOnce("warning: a problem occurred in builtin C++ name demangling; build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling")}return parsed}function demangleAll(text){return text.replace(/__Z[\w\d_]+/g,function(x){var y=demangle(x);return x===y?x:x+" ["+y+"]"})}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}function stackTrace(){return demangleAll(jsStackTrace())}Module["stackTrace"]=stackTrace;var PAGE_SIZE=4096;function alignMemoryPage(x){if(x%4096>0){x+=4096-x%4096}return x}var HEAP;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var STATIC_BASE=0,STATICTOP=0,staticSealed=false;var STACK_BASE=0,STACKTOP=0,STACK_MAX=0;var DYNAMIC_BASE=0,DYNAMICTOP=0;function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}function enlargeMemory(){abortOnCannotGrowMemory()}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||268435456;var totalMemory=64*1024;while(totalMemory0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Runtime.dynCall("v",func)}else{Runtime.dynCall("vi",func,[callback.arg])}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}Module["addOnPreRun"]=addOnPreRun;function addOnInit(cb){__ATINIT__.unshift(cb)}Module["addOnInit"]=addOnInit;function addOnPreMain(cb){__ATMAIN__.unshift(cb)}Module["addOnPreMain"]=addOnPreMain;function addOnExit(cb){__ATEXIT__.unshift(cb)}Module["addOnExit"]=addOnExit;function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}Module["addOnPostRun"]=addOnPostRun;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}Module["intArrayFromString"]=intArrayFromString;function intArrayToString(array){var ret=[];for(var i=0;i255){chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}Module["intArrayToString"]=intArrayToString;function writeStringToMemory(string,buffer,dontAddNull){var array=intArrayFromString(string,dontAddNull);var i=0;while(i>0]=chr;i=i+1}}Module["writeStringToMemory"]=writeStringToMemory;function writeArrayToMemory(array,buffer){for(var i=0;i>0]=array[i]}}Module["writeArrayToMemory"]=writeArrayToMemory;function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}Module["writeAsciiToMemory"]=writeAsciiToMemory;function unSign(value,bits,ignore){if(value>=0){return value}return bits<=32?2*Math.abs(1<=half&&(bits<=32||value>half)){value=-2*half+value}return value}if(!Math["imul"]||Math["imul"](4294967295,5)!==-5)Math["imul"]=function imul(a,b){var ah=a>>>16;var al=a&65535;var bh=b>>>16;var bl=b&65535;return al*bl+(ah*bl+al*bh<<16)|0};Math.imul=Math["imul"];if(!Math["clz32"])Math["clz32"]=function(x){x=x>>>0;for(var i=0;i<32;i++){if(x&1<<31-i)return i}return 32};Math.clz32=Math["clz32"];var Math_abs=Math.abs;var Math_cos=Math.cos;var Math_sin=Math.sin;var Math_tan=Math.tan;var Math_acos=Math.acos;var Math_asin=Math.asin;var Math_atan=Math.atan;var Math_atan2=Math.atan2;var Math_exp=Math.exp;var Math_log=Math.log;var Math_sqrt=Math.sqrt;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_pow=Math.pow;var Math_imul=Math.imul;var Math_fround=Math.fround;var Math_min=Math.min;var Math_clz32=Math.clz32;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}Module["addRunDependency"]=addRunDependency;function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["removeRunDependency"]=removeRunDependency;Module["preloadedImages"]={};Module["preloadedAudios"]={};var memoryInitializer=null;var ASM_CONSTS=[function($0,$1,$2,$3){{if(!artoolkit["multiEachMarkerInfo"]){artoolkit["multiEachMarkerInfo"]={}}var multiEachMarker=artoolkit["multiEachMarkerInfo"];multiEachMarker["visible"]=$0;multiEachMarker["pattId"]=$1;multiEachMarker["pattType"]=$2;multiEachMarker["width"]=$3}},function($0,$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32){{var $a=arguments;var i=12;if(!artoolkit["markerInfo"]){artoolkit["markerInfo"]={pos:[0,0],line:[[0,0,0],[0,0,0],[0,0,0],[0,0,0]],vertex:[[0,0],[0,0],[0,0],[0,0]]}}var markerInfo=artoolkit["markerInfo"];markerInfo["area"]=$0;markerInfo["id"]=$1;markerInfo["idPatt"]=$2;markerInfo["idMatrix"]=$3;markerInfo["dir"]=$4;markerInfo["dirPatt"]=$5;markerInfo["dirMatrix"]=$6;markerInfo["cf"]=$7;markerInfo["cfPatt"]=$8;markerInfo["cfMatrix"]=$9;markerInfo["pos"][0]=$10;markerInfo["pos"][1]=$11;markerInfo["line"][0][0]=$a[i++];markerInfo["line"][0][1]=$a[i++];markerInfo["line"][0][2]=$a[i++];markerInfo["line"][1][0]=$a[i++];markerInfo["line"][1][1]=$a[i++];markerInfo["line"][1][2]=$a[i++];markerInfo["line"][2][0]=$a[i++];markerInfo["line"][2][1]=$a[i++];markerInfo["line"][2][2]=$a[i++];markerInfo["line"][3][0]=$a[i++];markerInfo["line"][3][1]=$a[i++];markerInfo["line"][3][2]=$a[i++];markerInfo["vertex"][0][0]=$a[i++];markerInfo["vertex"][0][1]=$a[i++];markerInfo["vertex"][1][0]=$a[i++];markerInfo["vertex"][1][1]=$a[i++];markerInfo["vertex"][2][0]=$a[i++];markerInfo["vertex"][2][1]=$a[i++];markerInfo["vertex"][3][0]=$a[i++];markerInfo["vertex"][3][1]=$a[i++];markerInfo["errorCorrected"]=$a[i++]}},function($0,$1,$2,$3,$4){{if(!artoolkit["frameMalloc"]){artoolkit["frameMalloc"]={}}var frameMalloc=artoolkit["frameMalloc"];frameMalloc["framepointer"]=$1;frameMalloc["framesize"]=$2;frameMalloc["camera"]=$3;frameMalloc["transform"]=$4}}];function _emscripten_asm_const_33(code,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32){return ASM_CONSTS[code](a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32)}function _emscripten_asm_const_4(code,a0,a1,a2,a3){return ASM_CONSTS[code](a0,a1,a2,a3)}function _emscripten_asm_const_5(code,a0,a1,a2,a3,a4){return ASM_CONSTS[code](a0,a1,a2,a3,a4)}STATIC_BASE=8;STATICTOP=STATIC_BASE+16496;__ATINIT__.push({func:function(){__GLOBAL__sub_I_ARToolKitJS_cpp()}},{func:function(){__GLOBAL__sub_I_bind_cpp()}});allocate([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,9,0,0,53,42,0,0,0,0,0,0,1,0,0,0,128,1,0,0,0,0,0,0,228,8,0,0,116,42,0,0,52,9,0,0,136,47,0,0,0,0,0,0,1,0,0,0,128,1,0,0,0,0,0,0,52,9,0,0,73,47,0,0,0,0,0,0,1,0,0,0,128,1,0,0,0,0,0,0,228,8,0,0,54,47,0,0,228,8,0,0,23,47,0,0,228,8,0,0,62,46,0,0,228,8,0,0,31,46,0,0,228,8,0,0,0,46,0,0,228,8,0,0,225,45,0,0,228,8,0,0,194,45,0,0,228,8,0,0,93,46,0,0,228,8,0,0,124,46,0,0,228,8,0,0,155,46,0,0,228,8,0,0,186,46,0,0,228,8,0,0,217,46,0,0,228,8,0,0,248,46,0,0,12,9,0,0,199,47,0,0,48,2,0,0,0,0,0,0,228,8,0,0,212,47,0,0,228,8,0,0,225,47,0,0,12,9,0,0,238,47,0,0,56,2,0,0,0,0,0,0,12,9,0,0,15,48,0,0,64,2,0,0,0,0,0,0,12,9,0,0,49,48,0,0,64,2,0,0,0,0,0,0,200,8,0,0,89,48,0,0,200,8,0,0,91,48,0,0,200,8,0,0,93,48,0,0,200,8,0,0,95,48,0,0,200,8,0,0,97,48,0,0,200,8,0,0,99,48,0,0,200,8,0,0,101,48,0,0,200,8,0,0,103,48,0,0,200,8,0,0,105,48,0,0,200,8,0,0,107,48,0,0,200,8,0,0,109,48,0,0,200,8,0,0,111,48,0,0,200,8,0,0,113,48,0,0,12,9,0,0,115,48,0,0,80,2,0,0,0,0,0,0,12,9,0,0,152,48,0,0,80,2,0,0,0,0,0,0,255,15,0,0,6,16,0,0,18,16,0,0,28,16,0,0,255,255,255,255,255,255,255,255,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,1,0,0,0,2,0,0,0,4,0,0,0,8,0,0,0,3,0,0,0,6,0,0,0,12,0,0,0,11,0,0,0,5,0,0,0,10,0,0,0,7,0,0,0,14,0,0,0,15,0,0,0,13,0,0,0,9,0,0,0,1,0,0,0,2,0,0,0,4,0,0,0,8,0,0,0,16,0,0,0,32,0,0,0,64,0,0,0,3,0,0,0,6,0,0,0,12,0,0,0,24,0,0,0,48,0,0,0,96,0,0,0,67,0,0,0,5,0,0,0,10,0,0,0,20,0,0,0,40,0,0,0,80,0,0,0,35,0,0,0,70,0,0,0,15,0,0,0,30,0,0,0,60,0,0,0,120,0,0,0,115,0,0,0,101,0,0,0,73,0,0,0,17,0,0,0,34,0,0,0,68,0,0,0,11,0,0,0,22,0,0,0,44,0,0,0,88,0,0,0,51,0,0,0,102,0,0,0,79,0,0,0,29,0,0,0,58,0,0,0,116,0,0,0,107,0,0,0,85,0,0,0,41,0,0,0,82,0,0,0,39,0,0,0,78,0,0,0,31,0,0,0,62,0,0,0,124,0,0,0,123,0,0,0,117,0,0,0,105,0,0,0,81,0,0,0,33,0,0,0,66,0,0,0,7,0,0,0,14,0,0,0,28,0,0,0,56,0,0,0,112,0,0,0,99,0,0,0,69,0,0,0,9,0,0,0,18,0,0,0,36,0,0,0,72,0,0,0,19,0,0,0,38,0,0,0,76,0,0,0,27,0,0,0,54,0,0,0,108,0,0,0,91,0,0,0,53,0,0,0,106,0,0,0,87,0,0,0,45,0,0,0,90,0,0,0,55,0,0,0,110,0,0,0,95,0,0,0,61,0,0,0,122,0,0,0,119,0,0,0,109,0,0,0,89,0,0,0,49,0,0,0,98,0,0,0,71,0,0,0,13,0,0,0,26,0,0,0,52,0,0,0,104,0,0,0,83,0,0,0,37,0,0,0,74,0,0,0,23,0,0,0,46,0,0,0,92,0,0,0,59,0,0,0,118,0,0,0,111,0,0,0,93,0,0,0,57,0,0,0,114,0,0,0,103,0,0,0,77,0,0,0,25,0,0,0,50,0,0,0,100,0,0,0,75,0,0,0,21,0,0,0,42,0,0,0,84,0,0,0,43,0,0,0,86,0,0,0,47,0,0,0,94,0,0,0,63,0,0,0,126,0,0,0,127,0,0,0,125,0,0,0,121,0,0,0,113,0,0,0,97,0,0,0,65,0,0,0,255,255,255,255,0,0,0,0,1,0,0,0,4,0,0,0,2,0,0,0,8,0,0,0,5,0,0,0,10,0,0,0,3,0,0,0,14,0,0,0,9,0,0,0,7,0,0,0,6,0,0,0,13,0,0,0,11,0,0,0,12,0,0,0,255,255,255,255,0,0,0,0,1,0,0,0,7,0,0,0,2,0,0,0,14,0,0,0,8,0,0,0,56,0,0,0,3,0,0,0,63,0,0,0,15,0,0,0,31,0,0,0,9,0,0,0,90,0,0,0,57,0,0,0,21,0,0,0,4,0,0,0,28,0,0,0,64,0,0,0,67,0,0,0,16,0,0,0,112,0,0,0,32,0,0,0,97,0,0,0,10,0,0,0,108,0,0,0,91,0,0,0,70,0,0,0,58,0,0,0,38,0,0,0,22,0,0,0,47,0,0,0,5,0,0,0,54,0,0,0,29,0,0,0,19,0,0,0,65,0,0,0,95,0,0,0,68,0,0,0,45,0,0,0,17,0,0,0,43,0,0,0,113,0,0,0,115,0,0,0,33,0,0,0,77,0,0,0,98,0,0,0,117,0,0,0,11,0,0,0,87,0,0,0,109,0,0,0,35,0,0,0,92,0,0,0,74,0,0,0,71,0,0,0,79,0,0,0,59,0,0,0,104,0,0,0,39,0,0,0,100,0,0,0,23,0,0,0,82,0,0,0,48,0,0,0,119,0,0,0,6,0,0,0,126,0,0,0,55,0,0,0,13,0,0,0,30,0,0,0,62,0,0,0,20,0,0,0,89,0,0,0,66,0,0,0,27,0,0,0,96,0,0,0,111,0,0,0,69,0,0,0,107,0,0,0,46,0,0,0,37,0,0,0,18,0,0,0,53,0,0,0,44,0,0,0,94,0,0,0,114,0,0,0,42,0,0,0,116,0,0,0,76,0,0,0,34,0,0,0,86,0,0,0,78,0,0,0,73,0,0,0,99,0,0,0,103,0,0,0,118,0,0,0,81,0,0,0,12,0,0,0,125,0,0,0,88,0,0,0,61,0,0,0,110,0,0,0,26,0,0,0,36,0,0,0,106,0,0,0,93,0,0,0,52,0,0,0,75,0,0,0,41,0,0,0,72,0,0,0,85,0,0,0,80,0,0,0,102,0,0,0,60,0,0,0,124,0,0,0,105,0,0,0,25,0,0,0,40,0,0,0,51,0,0,0,101,0,0,0,84,0,0,0,24,0,0,0,123,0,0,0,83,0,0,0,50,0,0,0,49,0,0,0,122,0,0,0,120,0,0,0,121,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,136,0,0,0,5,0,0,0,144,0,0,0,6,0,0,0,152,0,0,0,9,0,0,0,176,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,253,255,255,255,254,255,255,255,0,0,0,0,112,2,0,0,168,2,0,0,200,2,0,0,112,2,0,0,168,2,0,0,168,2,0,0,208,2,0,0,168,2,0,0,112,2,0,0,168,2,0,0,208,2,0,0,168,2,0,0,112,2,0,0,168,2,0,0,168,2,0,0,104,1,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,104,1,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,168,2,0,0,0,0,0,0,32,2,0,0,1,0,0,0,2,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,96,2,0,0,3,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,1,0,0,0,0,0,0,0,80,2,0,0,3,0,0,0,7,0,0,0,5,0,0,0,6,0,0,0,2,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,216,2,0,0,3,0,0,0,8,0,0,0,5,0,0,0,6,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,232,2,0,0,3,0,0,0,9,0,0,0,5,0,0,0,6,0,0,0,2,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,192,3,0,0,192,4,0,0,192,5,0,0,192,6,0,0,192,7,0,0,192,8,0,0,192,9,0,0,192,10,0,0,192,11,0,0,192,12,0,0,192,13,0,0,192,14,0,0,192,15,0,0,192,16,0,0,192,17,0,0,192,18,0,0,192,19,0,0,192,20,0,0,192,21,0,0,192,22,0,0,192,23,0,0,192,24,0,0,192,25,0,0,192,26,0,0,192,27,0,0,192,28,0,0,192,29,0,0,192,30,0,0,192,31,0,0,192,0,0,0,179,1,0,0,195,2,0,0,195,3,0,0,195,4,0,0,195,5,0,0,195,6,0,0,195,7,0,0,195,8,0,0,195,9,0,0,195,10,0,0,195,11,0,0,195,12,0,0,195,13,0,0,211,14,0,0,195,15,0,0,195,0,0,12,187,1,0,12,195,2,0,12,195,3,0,12,195,4,0,12,211,240,10,0,0,96,11,0,0,0,0,0,0,10,0,0,0,100,0,0,0,232,3,0,0,16,39,0,0,160,134,1,0,64,66,15,0,128,150,152,0,0,225,245,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,5,0,0,0,81,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,5,0,0,0,73,58,0,0,0,4,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,5,0,0,0,7,0,0,0,11,0,0,0,13,0,0,0,17,0,0,0,19,0,0,0,23,0,0,0,29,0,0,0,31,0,0,0,37,0,0,0,41,0,0,0,43,0,0,0,47,0,0,0,53,0,0,0,59,0,0,0,61,0,0,0,67,0,0,0,71,0,0,0,73,0,0,0,79,0,0,0,83,0,0,0,89,0,0,0,97,0,0,0,101,0,0,0,103,0,0,0,107,0,0,0,109,0,0,0,113,0,0,0,127,0,0,0,131,0,0,0,137,0,0,0,139,0,0,0,149,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,167,0,0,0,173,0,0,0,179,0,0,0,181,0,0,0,191,0,0,0,193,0,0,0,197,0,0,0,199,0,0,0,211,0,0,0,1,0,0,0,11,0,0,0,13,0,0,0,17,0,0,0,19,0,0,0,23,0,0,0,29,0,0,0,31,0,0,0,37,0,0,0,41,0,0,0,43,0,0,0,47,0,0,0,53,0,0,0,59,0,0,0,61,0,0,0,67,0,0,0,71,0,0,0,73,0,0,0,79,0,0,0,83,0,0,0,89,0,0,0,97,0,0,0,101,0,0,0,103,0,0,0,107,0,0,0,109,0,0,0,113,0,0,0,121,0,0,0,127,0,0,0,131,0,0,0,137,0,0,0,139,0,0,0,143,0,0,0,149,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,167,0,0,0,169,0,0,0,173,0,0,0,179,0,0,0,181,0,0,0,187,0,0,0,191,0,0,0,193,0,0,0,197,0,0,0,199,0,0,0,209,0,0,0,69,114,114,111,114,58,32,108,97,98,101,108,105,110,103,32,119,111,114,107,32,111,118,101,114,102,108,111,119,46,10,0,69,114,114,111,114,58,32,85,110,115,117,112,112,111,114,116,101,100,32,112,105,120,101,108,32,102,111,114,109,97,116,32,40,37,100,41,32,114,101,113,117,101,115,116,101,100,46,10,0,85,110,107,110,111,119,110,32,111,114,32,117,110,115,117,112,112,111,114,116,101,100,32,108,97,98,101,108,105,110,103,32,116,104,114,101,115,104,111,108,100,32,109,111,100,101,32,114,101,113,117,101,115,116,101,100,46,32,83,101,116,32,116,111,32,109,97,110,117,97,108,46,10,0,76,97,98,101,108,105,110,103,32,116,104,114,101,115,104,111,108,100,32,109,111,100,101,32,115,101,116,32,116,111,32,37,115,46,10,0,77,65,78,85,65,76,0,65,85,84,79,95,77,69,68,73,65,78,0,65,85,84,79,95,79,84,83,85,0,65,85,84,79,95,65,68,65,80,84,73,86,69,65,85,84,79,95,66,82,65,67,75,69,84,73,78,71,0,65,117,116,111,32,116,104,114,101,115,104,111,108,100,32,40,98,114,97,99,107,101,116,41,32,109,97,114,107,101,114,32,99,111,117,110,116,115,32,45,91,37,51,100,58,32,37,51,100,93,32,91,37,51,100,58,32,37,51,100,93,32,91,37,51,100,58,32,37,51,100,93,43,46,10,0,65,117,116,111,32,116,104,114,101,115,104,111,108,100,32,40,98,114,97,99,107,101,116,41,32,97,100,106,117,115,116,101,100,32,116,104,114,101,115,104,111,108,100,32,116,111,32,37,100,46,10,0,109,101,100,105,97,110,0,79,116,115,117,0,65,117,116,111,32,116,104,114,101,115,104,111,108,100,32,40,37,115,41,32,97,100,106,117,115,116,101,100,32,116,104,114,101,115,104,111,108,100,32,116,111,32,37,100,46,10,0,63,63,63,32,49,10,0,63,63,63,32,50,10,0,63,63,63,32,51,10,0,69,114,114,111,114,58,32,85,110,115,117,112,112,111,114,116,101,100,32,112,105,120,101,108,32,102,111,114,109,97,116,32,112,97,115,115,101,100,32,116,111,32,97,114,73,109,97,103,101,80,114,111,99,72,105,115,116,40,41,46,10,0,0,0,0,1,0,1,1,1,0,2,4,255,255,5,3,1,0,2,255,6,7,255,3,1,2,2,3,2,3,2,3,3,0,255,4,6,7,5,255,1,4,5,4,4,5,5,4,5,7,6,6,6,7,7,7,6,255,2,4,6,7,5,3,255,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,1,1,0,1,1,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,0,1,1,0,1,1,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,255,255,3,255,5,6,255,255,9,10,255,12,255,255,15,255,17,18,255,20,255,255,23,24,255,255,27,255,29,30,255,255,1,2,255,4,255,255,7,8,255,255,11,255,13,14,255,16,255,255,19,255,21,22,255,255,25,26,255,28,255,255,31,69,114,114,111,114,58,32,117,110,115,117,112,112,111,114,116,101,100,32,112,105,120,101,108,32,102,111,114,109,97,116,46,10,0,69,114,114,111,114,58,32,78,85,76,76,32,112,97,116,116,72,97,110,100,108,101,46,10,0,69,114,114,111,114,58,32,99,97,110,39,116,32,108,111,97,100,32,112,97,116,116,101,114,110,32,102,114,111,109,32,78,85,76,76,32,98,117,102,102,101,114,46,10,0,69,114,114,111,114,58,32,111,117,116,32,111,102,32,109,101,109,111,114,121,46,10,0,32,9,10,13,0,80,97,116,116,101,114,110,32,68,97,116,97,32,114,101,97,100,32,101,114,114,111,114,33,33,10,0,69,114,114,111,114,32,111,112,101,110,105,110,103,32,112,97,116,116,101,114,110,32,102,105,108,101,32,39,37,115,39,32,102,111,114,32,114,101,97,100,105,110,103,46,10,0,69,114,114,111,114,32,114,101,97,100,105,110,103,32,112,97,116,116,101,114,110,32,102,105,108,101,32,39,37,115,39,46,10,0,114,98,0,69,114,114,111,114,32,40,37,100,41,58,32,117,110,97,98,108,101,32,116,111,32,111,112,101,110,32,99,97,109,101,114,97,32,112,97,114,97,109,101,116,101,114,115,32,102,105,108,101,32,34,37,115,34,32,102,111,114,32,114,101,97,100,105,110,103,46,10,0,69,114,114,111,114,32,40,37,100,41,58,32,117,110,97,98,108,101,32,116,111,32,100,101,116,101,114,109,105,110,101,32,102,105,108,101,32,108,101,110,103,116,104,46,0,69,114,114,111,114,58,32,115,117,112,112,108,105,101,100,32,102,105,108,101,32,100,111,101,115,32,110,111,116,32,97,112,112,101,97,114,32,116,111,32,98,101,32,97,110,32,65,82,84,111,111,108,75,105,116,32,99,97,109,101,114,97,32,112,97,114,97,109,101,116,101,114,32,102,105,108,101,46,10,0,69,114,114,111,114,32,40,37,100,41,58,32,117,110,97,98,108,101,32,116,111,32,114,101,97,100,32,102,114,111,109,32,102,105,108,101,46,0,69,114,114,111,114,58,32,105,99,112,71,101,116,74,95,85,95,88,99,0,69,114,114,111,114,58,32,109,97,108,108,111,99,10,0,69,114,114,111,114,32,49,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,50,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,51,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,52,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,53,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,54,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,69,114,114,111,114,32,55,58,32,105,99,112,71,101,116,73,110,105,116,88,119,50,88,99,10,0,114,0,69,114,114,111,114,58,32,117,110,97,98,108,101,32,116,111,32,111,112,101,110,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,46,10,0,37,115,37,115,10,0,0,37,100,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,58,32,70,105,114,115,116,32,108,105,110,101,32,109,117,115,116,32,98,101,32,110,117,109,98,101,114,32,111,102,32,109,97,114,107,101,114,32,99,111,110,102,105,103,115,32,116,111,32,114,101,97,100,46,10,0,79,117,116,32,111,102,32,109,101,109,111,114,121,33,33,10,0,37,108,108,117,37,99,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,58,32,112,97,116,116,101,114,110,32,39,37,115,39,32,115,112,101,99,105,102,105,101,100,32,105,110,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,117,114,97,116,105,111,110,32,119,104,105,108,101,32,105,110,32,98,97,114,99,111,100,101,45,111,110,108,121,32,109,111,100,101,46,10,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,58,32,85,110,97,98,108,101,32,116,111,32,100,101,116,101,114,109,105,110,101,32,100,105,114,101,99,116,111,114,121,32,110,97,109,101,46,10,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,58,32,85,110,97,98,108,101,32,116,111,32,108,111,97,100,32,112,97,116,116,101,114,110,32,39,37,115,39,46,10,0,37,108,102,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,44,32,109,97,114,107,101,114,32,100,101,102,105,110,105,116,105,111,110,32,37,51,100,58,32,70,105,114,115,116,32,108,105,110,101,32,109,117,115,116,32,98,101,32,112,97,116,116,101,114,110,32,119,105,100,116,104,46,10,0,37,108,102,32,37,108,102,32,37,108,102,32,37,108,102,0,37,102,32,37,102,0,69,114,114,111,114,32,112,114,111,99,101,115,115,105,110,103,32,109,117,108,116,105,109,97,114,107,101,114,32,99,111,110,102,105,103,32,102,105,108,101,32,39,37,115,39,44,32,109,97,114,107,101,114,32,100,101,102,105,110,105,116,105,111,110,32,37,51,100,58,32,76,105,110,101,115,32,50,32,45,32,52,32,109,117,115,116,32,98,101,32,109,97,114,107,101,114,32,116,114,97,110,115,102,111,114,109,46,10,0,97,114,103,108,67,97,109,101,114,97,70,114,117,115,116,117,109,40,41,58,32,97,114,80,97,114,97,109,68,101,99,111,109,112,77,97,116,40,41,32,105,110,100,105,99,97,116,101,100,32,112,97,114,97,109,101,116,101,114,32,101,114,114,111,114,46,10,0,108,111,97,100,67,97,109,101,114,97,40,41,58,32,69,114,114,111,114,32,108,111,97,100,105,110,103,32,112,97,114,97,109,101,116,101,114,32,102,105,108,101,32,37,115,32,102,111,114,32,99,97,109,101,114,97,46,10,0,42,42,42,32,67,97,109,101,114,97,32,80,97,114,97,109,101,116,101,114,32,114,101,115,105,122,101,100,32,102,114,111,109,32,37,100,44,32,37,100,46,32,42,42,42,10,0,115,101,116,67,97,109,101,114,97,40,41,58,32,69,114,114,111,114,58,32,97,114,80,97,114,97,109,76,84,67,114,101,97,116,101,46,10,0,115,101,116,67,97,109,101,114,97,40,41,58,32,69,114,114,111,114,58,32,97,114,67,114,101,97,116,101,72,97,110,100,108,101,46,10,0,115,101,116,67,97,109,101,114,97,40,41,58,32,69,114,114,111,114,32,99,114,101,97,116,105,110,103,32,51,68,32,104,97,110,100,108,101,0,108,111,97,100,77,97,114,107,101,114,40,41,58,32,69,114,114,111,114,32,108,111,97,100,105,110,103,32,112,97,116,116,101,114,110,32,102,105,108,101,32,37,115,46,10,0,65,82,84,111,111,108,75,105,116,74,83,40,41,58,32,85,110,97,98,108,101,32,116,111,32,115,101,116,32,117,112,32,65,82,32,109,97,114,107,101,114,46,10,0,99,111,110,102,105,103,32,100,97,116,97,32,108,111,97,100,32,101,114,114,111,114,32,33,33,10,0,65,82,84,111,111,108,75,105,116,74,83,40,41,58,32,85,110,97,98,108,101,32,116,111,32,115,101,116,32,117,112,32,65,82,32,109,117,108,116,105,109,97,114,107,101,114,46,10,0,80,97,116,116,101,114,110,32,100,101,116,101,99,116,105,111,110,32,109,111,100,101,32,115,101,116,32,116,111,32,37,100,46,10,0,80,97,116,116,101,114,110,32,114,97,116,105,111,32,115,105,122,101,32,115,101,116,32,116,111,32,37,102,46,10,0,76,97,98,101,108,105,110,103,32,109,111,100,101,32,115,101,116,32,116,111,32,37,100,10,0,84,104,114,101,115,104,111,108,100,32,115,101,116,32,116,111,32,37,100,10,0,84,104,114,101,115,104,111,108,100,32,109,111,100,101,32,115,101,116,32,116,111,32,37,100,10,0,111,110,46,0,111,102,102,46,0,68,101,98,117,103,32,109,111,100,101,32,115,101,116,32,116,111,32,37,115,10,0,73,109,97,103,101,32,112,114,111,99,46,32,109,111,100,101,32,115,101,116,32,116,111,32,37,100,46,10,0,123,32,105,102,32,40,33,97,114,116,111,111,108,107,105,116,91,34,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,73,110,102,111,34,93,41,32,123,32,97,114,116,111,111,108,107,105,116,91,34,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,73,110,102,111,34,93,32,61,32,40,123,125,41,59,32,125,32,118,97,114,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,32,61,32,97,114,116,111,111,108,107,105,116,91,34,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,73,110,102,111,34,93,59,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,91,39,118,105,115,105,98,108,101,39,93,32,61,32,36,48,59,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,91,39,112,97,116,116,73,100,39,93,32,61,32,36,49,59,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,91,39,112,97,116,116,84,121,112,101,39,93,32,61,32,36,50,59,32,109,117,108,116,105,69,97,99,104,77,97,114,107,101,114,91,39,119,105,100,116,104,39,93,32,61,32,36,51,59,32,125,0,123,32,118,97,114,32,36,97,32,61,32,97,114,103,117,109,101,110,116,115,59,32,118,97,114,32,105,32,61,32,49,50,59,32,105,102,32,40,33,97,114,116,111,111,108,107,105,116,91,34,109,97,114,107,101,114,73,110,102,111,34,93,41,32,123,32,97,114,116,111,111,108,107,105,116,91,34,109,97,114,107,101,114,73,110,102,111,34,93,32,61,32,40,123,32,112,111,115,58,32,91,48,44,48,93,44,32,108,105,110,101,58,32,91,91,48,44,48,44,48,93,44,32,91,48,44,48,44,48,93,44,32,91,48,44,48,44,48,93,44,32,91,48,44,48,44,48,93,93,44,32,118,101,114,116,101,120,58,32,91,91,48,44,48,93,44,32,91,48,44,48,93,44,32,91,48,44,48,93,44,32,91,48,44,48,93,93,32,125,41,59,32,125,32,118,97,114,32,109,97,114,107,101,114,73,110,102,111,32,61,32,97,114,116,111,111,108,107,105,116,91,34,109,97,114,107,101,114,73,110,102,111,34,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,97,114,101,97,34,93,32,61,32,36,48,59,32,109,97,114,107,101,114,73,110,102,111,91,34,105,100,34,93,32,61,32,36,49,59,32,109,97,114,107,101,114,73,110,102,111,91,34,105,100,80,97,116,116,34,93,32,61,32,36,50,59,32,109,97,114,107,101,114,73,110,102,111,91,34,105,100,77,97,116,114,105,120,34,93,32,61,32,36,51,59,32,109,97,114,107,101,114,73,110,102,111,91,34,100,105,114,34,93,32,61,32,36,52,59,32,109,97,114,107,101,114,73,110,102,111,91,34,100,105,114,80,97,116,116,34,93,32,61,32,36,53,59,32,109,97,114,107,101,114,73,110,102,111,91,34,100,105,114,77,97,116,114,105,120,34,93,32,61,32,36,54,59,32,109,97,114,107,101,114,73,110,102,111,91,34,99,102,34,93,32,61,32,36,55,59,32,109,97,114,107,101,114,73,110,102,111,91,34,99,102,80,97,116,116,34,93,32,61,32,36,56,59,32,109,97,114,107,101,114,73,110,102,111,91,34,99,102,77,97,116,114,105,120,34,93,32,61,32,36,57,59,32,109,97,114,107,101,114,73,110,102,111,91,34,112,111,115,34,93,91,48,93,32,61,32,36,49,48,59,32,109,97,114,107,101,114,73,110,102,111,91,34,112,111,115,34,93,91,49,93,32,61,32,36,49,49,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,48,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,48,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,48,93,91,50,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,49,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,49,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,49,93,91,50,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,50,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,50,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,50,93,91,50,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,51,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,51,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,108,105,110,101,34,93,91,51,93,91,50,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,48,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,48,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,49,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,49,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,50,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,50,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,51,93,91,48,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,118,101,114,116,101,120,34,93,91,51,93,91,49,93,32,61,32,36,97,91,105,43,43,93,59,32,109,97,114,107,101,114,73,110,102,111,91,34,101,114,114,111,114,67,111,114,114,101,99,116,101,100,34,93,32,61,32,36,97,91,105,43,43,93,59,32,125,0,115,101,116,117,112,40,41,58,32,69,114,114,111,114,58,32,97,114,80,97,116,116,67,114,101,97,116,101,72,97,110,100,108,101,46,10,0,65,108,108,111,99,97,116,101,100,32,118,105,100,101,111,70,114,97,109,101,83,105,122,101,32,37,100,10,0,123,32,105,102,32,40,33,97,114,116,111,111,108,107,105,116,91,34,102,114,97,109,101,77,97,108,108,111,99,34,93,41,32,123,32,97,114,116,111,111,108,107,105,116,91,34,102,114,97,109,101,77,97,108,108,111,99,34,93,32,61,32,40,123,125,41,59,32,125,32,118,97,114,32,102,114,97,109,101,77,97,108,108,111,99,32,61,32,97,114,116,111,111,108,107,105,116,91,34,102,114,97,109,101,77,97,108,108,111,99,34,93,59,32,102,114,97,109,101,77,97,108,108,111,99,91,34,102,114,97,109,101,112,111,105,110,116,101,114,34,93,32,61,32,36,49,59,32,102,114,97,109,101,77,97,108,108,111,99,91,34,102,114,97,109,101,115,105,122,101,34,93,32,61,32,36,50,59,32,102,114,97,109,101,77,97,108,108,111,99,91,34,99,97,109,101,114,97,34,93,32,61,32,36,51,59,32,102,114,97,109,101,77,97,108,108,111,99,91,34,116,114,97,110,115,102,111,114,109,34,93,32,61,32,36,52,59,32,125,0,115,101,116,117,112,0,116,101,97,114,100,111,119,110,0,95,97,100,100,77,97,114,107,101,114,0,95,97,100,100,77,117,108,116,105,77,97,114,107,101,114,0,103,101,116,77,117,108,116,105,77,97,114,107,101,114,78,117,109,0,103,101,116,77,117,108,116,105,77,97,114,107,101,114,67,111,117,110,116,0,95,108,111,97,100,67,97,109,101,114,97,0,115,101,116,77,97,114,107,101,114,73,110,102,111,68,105,114,0,115,101,116,77,97,114,107,101,114,73,110,102,111,86,101,114,116,101,120,0,103,101,116,84,114,97,110,115,77,97,116,83,113,117,97,114,101,0,103,101,116,84,114,97,110,115,77,97,116,83,113,117,97,114,101,67,111,110,116,0,103,101,116,84,114,97,110,115,77,97,116,77,117,108,116,105,83,113,117,97,114,101,0,103,101,116,84,114,97,110,115,77,97,116,77,117,108,116,105,83,113,117,97,114,101,82,111,98,117,115,116,0,100,101,116,101,99,116,77,97,114,107,101,114,0,103,101,116,77,97,114,107,101,114,78,117,109,0,103,101,116,77,117,108,116,105,69,97,99,104,77,97,114,107,101,114,0,103,101,116,77,97,114,107,101,114,0,115,101,116,68,101,98,117,103,77,111,100,101,0,103,101,116,68,101,98,117,103,77,111,100,101,0,103,101,116,80,114,111,99,101,115,115,105,110,103,73,109,97,103,101,0,115,101,116,76,111,103,76,101,118,101,108,0,103,101,116,76,111,103,76,101,118,101,108,0,115,101,116,80,114,111,106,101,99,116,105,111,110,78,101,97,114,80,108,97,110,101,0,103,101,116,80,114,111,106,101,99,116,105,111,110,78,101,97,114,80,108,97,110,101,0,115,101,116,80,114,111,106,101,99,116,105,111,110,70,97,114,80,108,97,110,101,0,103,101,116,80,114,111,106,101,99,116,105,111,110,70,97,114,80,108,97,110,101,0,115,101,116,84,104,114,101,115,104,111,108,100,77,111,100,101,0,103,101,116,84,104,114,101,115,104,111,108,100,77,111,100,101,0,115,101,116,84,104,114,101,115,104,111,108,100,0,103,101,116,84,104,114,101,115,104,111,108,100,0,115,101,116,80,97,116,116,101,114,110,68,101,116,101,99,116,105,111,110,77,111,100,101,0,103,101,116,80,97,116,116,101,114,110,68,101,116,101,99,116,105,111,110,77,111,100,101,0,115,101,116,80,97,116,116,82,97,116,105,111,0,103,101,116,80,97,116,116,82,97,116,105,111,0,115,101,116,77,97,116,114,105,120,67,111,100,101,84,121,112,101,0,103,101,116,77,97,116,114,105,120,67,111,100,101,84,121,112,101,0,115,101,116,76,97,98,101,108,105,110,103,77,111,100,101,0,103,101,116,76,97,98,101,108,105,110,103,77,111,100,101,0,115,101,116,73,109,97,103,101,80,114,111,99,77,111,100,101,0,103,101,116,73,109,97,103,101,80,114,111,99,77,111,100,101,0,69,82,82,79,82,95,65,82,67,79,78,84,82,79,76,76,69,82,95,78,79,84,95,70,79,85,78,68,0,69,82,82,79,82,95,77,85,76,84,73,77,65,82,75,69,82,95,78,79,84,95,70,79,85,78,68,0,69,82,82,79,82,95,77,65,82,75,69,82,95,73,78,68,69,88,95,79,85,84,95,79,70,95,66,79,85,78,68,83,0,65,82,95,68,69,66,85,71,95,68,73,83,65,66,76,69,0,65,82,95,68,69,66,85,71,95,69,78,65,66,76,69,0,65,82,95,68,69,70,65,85,76,84,95,68,69,66,85,71,95,77,79,68,69,0,65,82,95,76,65,66,69,76,73,78,71,95,87,72,73,84,69,95,82,69,71,73,79,78,0,65,82,95,76,65,66,69,76,73,78,71,95,66,76,65,67,75,95,82,69,71,73,79,78,0,65,82,95,68,69,70,65,85,76,84,95,76,65,66,69,76,73,78,71,95,77,79,68,69,0,65,82,95,68,69,70,65,85,76,84,95,76,65,66,69,76,73,78,71,95,84,72,82,69,83,72,0,65,82,95,73,77,65,71,69,95,80,82,79,67,95,70,82,65,77,69,95,73,77,65,71,69,0,65,82,95,73,77,65,71,69,95,80,82,79,67,95,70,73,69,76,68,95,73,77,65,71,69,0,65,82,95,68,69,70,65,85,76,84,95,73,77,65,71,69,95,80,82,79,67,95,77,79,68,69,0,65,82,95,84,69,77,80,76,65,84,69,95,77,65,84,67,72,73,78,71,95,67,79,76,79,82,0,65,82,95,84,69,77,80,76,65,84,69,95,77,65,84,67,72,73,78,71,95,77,79,78,79,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,68,69,84,69,67,84,73,79,78,0,65,82,95,84,69,77,80,76,65,84,69,95,77,65,84,67,72,73,78,71,95,67,79,76,79,82,95,65,78,68,95,77,65,84,82,73,88,0,65,82,95,84,69,77,80,76,65,84,69,95,77,65,84,67,72,73,78,71,95,77,79,78,79,95,65,78,68,95,77,65,84,82,73,88,0,65,82,95,68,69,70,65,85,76,84,95,80,65,84,84,69,82,78,95,68,69,84,69,67,84,73,79,78,95,77,79,68,69,0,65,82,95,85,83,69,95,84,82,65,67,75,73,78,71,95,72,73,83,84,79,82,89,0,65,82,95,78,79,85,83,69,95,84,82,65,67,75,73,78,71,95,72,73,83,84,79,82,89,0,65,82,95,85,83,69,95,84,82,65,67,75,73,78,71,95,72,73,83,84,79,82,89,95,86,50,0,65,82,95,68,69,70,65,85,76,84,95,77,65,82,75,69,82,95,69,88,84,82,65,67,84,73,79,78,95,77,79,68,69,0,65,82,95,77,65,88,95,76,79,79,80,95,67,79,85,78,84,0,65,82,95,76,79,79,80,95,66,82,69,65,75,95,84,72,82,69,83,72,0,65,82,95,76,79,71,95,76,69,86,69,76,95,68,69,66,85,71,0,65,82,95,76,79,71,95,76,69,86,69,76,95,73,78,70,79,0,65,82,95,76,79,71,95,76,69,86,69,76,95,87,65,82,78,0,65,82,95,76,79,71,95,76,69,86,69,76,95,69,82,82,79,82,0,65,82,95,76,79,71,95,76,69,86,69,76,95,82,69,76,95,73,78,70,79,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,51,120,51,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,51,120,51,95,72,65,77,77,73,78,71,54,51,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,51,120,51,95,80,65,82,73,84,89,54,53,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,52,120,52,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,52,120,52,95,66,67,72,95,49,51,95,57,95,51,0,65,82,95,77,65,84,82,73,88,95,67,79,68,69,95,52,120,52,95,66,67,72,95,49,51,95,53,95,53,0,65,82,95,76,65,66,69,76,73,78,71,95,84,72,82,69,83,72,95,77,79,68,69,95,77,65,78,85,65,76,0,65,82,95,76,65,66,69,76,73,78,71,95,84,72,82,69,83,72,95,77,79,68,69,95,65,85,84,79,95,77,69,68,73,65,78,0,65,82,95,76,65],"i8",ALLOC_NONE,Runtime.GLOBAL_BASE); allocate([66,69,76,73,78,71,95,84,72,82,69,83,72,95,77,79,68,69,95,65,85,84,79,95,79,84,83,85,0,65,82,95,76,65,66,69,76,73,78,71,95,84,72,82,69,83,72,95,77,79,68,69,95,65,85,84,79,95,65,68,65,80,84,73,86,69,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,78,79,78,69,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,80,65,84,84,69,82,78,95,69,88,84,82,65,67,84,73,79,78,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,77,65,84,67,72,95,71,69,78,69,82,73,67,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,77,65,84,67,72,95,67,79,78,84,82,65,83,84,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,77,65,84,67,72,95,66,65,82,67,79,68,69,95,78,79,84,95,70,79,85,78,68,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,77,65,84,67,72,95,66,65,82,67,79,68,69,95,69,68,67,95,70,65,73,76,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,77,65,84,67,72,95,67,79,78,70,73,68,69,78,67,69,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,80,79,83,69,95,69,82,82,79,82,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,80,79,83,69,95,69,82,82,79,82,95,77,85,76,84,73,0,65,82,95,77,65,82,75,69,82,95,73,78,70,79,95,67,85,84,79,70,70,95,80,72,65,83,69,95,72,69,85,82,73,83,84,73,67,95,84,82,79,85,66,76,69,83,79,77,69,95,77,65,84,82,73,88,95,67,79,68,69,83,0,118,105,105,102,0,118,105,105,105,0,100,105,105,0,118,105,105,100,0,105,105,0,118,105,105,0,105,105,105,0,78,83,116,51,95,95,49,49,50,98,97,115,105,99,95,115,116,114,105,110,103,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,78,83,95,57,97,108,108,111,99,97,116,111,114,73,99,69,69,69,69,0,78,83,116,51,95,95,49,50,49,95,95,98,97,115,105,99,95,115,116,114,105,110,103,95,99,111,109,109,111,110,73,76,98,49,69,69,69,0,105,105,105,105,0,105,105,105,105,105,0,118,111,105,100,0,98,111,111,108,0,99,104,97,114,0,115,105,103,110,101,100,32,99,104,97,114,0,117,110,115,105,103,110,101,100,32,99,104,97,114,0,115,104,111,114,116,0,117,110,115,105,103,110,101,100,32,115,104,111,114,116,0,105,110,116,0,117,110,115,105,103,110,101,100,32,105,110,116,0,108,111,110,103,0,117,110,115,105,103,110,101,100,32,108,111,110,103,0,102,108,111,97,116,0,100,111,117,98,108,101,0,115,116,100,58,58,115,116,114,105,110,103,0,115,116,100,58,58,98,97,115,105,99,95,115,116,114,105,110,103,60,117,110,115,105,103,110,101,100,32,99,104,97,114,62,0,115,116,100,58,58,119,115,116,114,105,110,103,0,101,109,115,99,114,105,112,116,101,110,58,58,118,97,108,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,99,104,97,114,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,115,105,103,110,101,100,32,99,104,97,114,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,110,115,105,103,110,101,100,32,99,104,97,114,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,115,104,111,114,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,110,115,105,103,110,101,100,32,115,104,111,114,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,105,110,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,110,115,105,103,110,101,100,32,105,110,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,108,111,110,103,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,110,115,105,103,110,101,100,32,108,111,110,103,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,105,110,116,56,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,105,110,116,56,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,105,110,116,49,54,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,105,110,116,49,54,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,105,110,116,51,50,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,105,110,116,51,50,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,102,108,111,97,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,100,111,117,98,108,101,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,108,111,110,103,32,100,111,117,98,108,101,62,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,101,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,100,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,102,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,109,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,108,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,106,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,105,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,116,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,115,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,104,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,97,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,99,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,0,78,83,116,51,95,95,49,49,50,98,97,115,105,99,95,115,116,114,105,110,103,73,119,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,119,69,69,78,83,95,57,97,108,108,111,99,97,116,111,114,73,119,69,69,69,69,0,78,83,116,51,95,95,49,49,50,98,97,115,105,99,95,115,116,114,105,110,103,73,104,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,104,69,69,78,83,95,57,97,108,108,111,99,97,116,111,114,73,104,69,69,69,69,0,83,116,57,98,97,100,95,97,108,108,111,99,0,83,116,57,101,120,99,101,112,116,105,111,110,0,83,116,57,116,121,112,101,95,105,110,102,111,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,51,95,95,102,117,110,100,97,109,101,110,116,97,108,95,116,121,112,101,95,105,110,102,111,69,0,118,0,98,0,99,0,104,0,97,0,115,0,116,0,105,0,106,0,108,0,109,0,102,0,100,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,49,95,95,118,109,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,33,34,118,101,99,116,111,114,32,108,101,110,103,116,104,95,101,114,114,111,114,34,0,47,85,115,101,114,115,47,106,101,114,111,109,101,101,116,105,101,110,110,101,47,119,111,114,107,47,101,109,115,100,107,95,112,111,114,116,97,98,108,101,47,101,109,115,99,114,105,112,116,101,110,47,49,46,51,53,46,48,47,115,121,115,116,101,109,47,105,110,99,108,117,100,101,47,108,105,98,99,120,120,47,118,101,99,116,111,114,0,95,95,116,104,114,111,119,95,108,101,110,103,116,104,95,101,114,114,111,114,0,115,116,100,58,58,98,97,100,95,97,108,108,111,99,0,33,34,98,97,115,105,99,95,115,116,114,105,110,103,32,108,101,110,103,116,104,95,101,114,114,111,114,34,0,47,85,115,101,114,115,47,106,101,114,111,109,101,101,116,105,101,110,110,101,47,119,111,114,107,47,101,109,115,100,107,95,112,111,114,116,97,98,108,101,47,101,109,115,99,114,105,112,116,101,110,47,49,46,51,53,46,48,47,115,121,115,116,101,109,47,105,110,99,108,117,100,101,47,108,105,98,99,120,120,47,115,116,114,105,110,103,0,84,33,34,25,13,1,2,3,17,75,28,12,16,4,11,29,18,30,39,104,110,111,112,113,98,32,5,6,15,19,20,21,26,8,22,7,40,36,23,24,9,10,14,27,31,37,35,131,130,125,38,42,43,60,61,62,63,67,71,74,77,88,89,90,91,92,93,94,95,96,97,99,100,101,102,103,105,106,107,108,114,115,116,121,122,123,124,0,73,108,108,101,103,97,108,32,98,121,116,101,32,115,101,113,117,101,110,99,101,0,68,111,109,97,105,110,32,101,114,114,111,114,0,82,101,115,117,108,116,32,110,111,116,32,114,101,112,114,101,115,101,110,116,97,98,108,101,0,78,111,116,32,97,32,116,116,121,0,80,101,114,109,105,115,115,105,111,110,32,100,101,110,105,101,100,0,79,112,101,114,97,116,105,111,110,32,110,111,116,32,112,101,114,109,105,116,116,101,100,0,78,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121,0,78,111,32,115,117,99,104,32,112,114,111,99,101,115,115,0,70,105,108,101,32,101,120,105,115,116,115,0,86,97,108,117,101,32,116,111,111,32,108,97,114,103,101,32,102,111,114,32,100,97,116,97,32,116,121,112,101,0,78,111,32,115,112,97,99,101,32,108,101,102,116,32,111,110,32,100,101,118,105,99,101,0,79,117,116,32,111,102,32,109,101,109,111,114,121,0,82,101,115,111,117,114,99,101,32,98,117,115,121,0,73,110,116,101,114,114,117,112,116,101,100,32,115,121,115,116,101,109,32,99,97,108,108,0,82,101,115,111,117,114,99,101,32,116,101,109,112,111,114,97,114,105,108,121,32,117,110,97,118,97,105,108,97,98,108,101,0,73,110,118,97,108,105,100,32,115,101,101,107,0,67,114,111,115,115,45,100,101,118,105,99,101,32,108,105,110,107,0,82,101,97,100,45,111,110,108,121,32,102,105,108,101,32,115,121,115,116,101,109,0,68,105,114,101,99,116,111,114,121,32,110,111,116,32,101,109,112,116,121,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,112,101,101,114,0,79,112,101,114,97,116,105,111,110,32,116,105,109,101,100,32,111,117,116,0,67,111,110,110,101,99,116,105,111,110,32,114,101,102,117,115,101,100,0,72,111,115,116,32,105,115,32,100,111,119,110,0,72,111,115,116,32,105,115,32,117,110,114,101,97,99,104,97,98,108,101,0,65,100,100,114,101,115,115,32,105,110,32,117,115,101,0,66,114,111,107,101,110,32,112,105,112,101,0,73,47,79,32,101,114,114,111,114,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,32,111,114,32,97,100,100,114,101,115,115,0,66,108,111,99,107,32,100,101,118,105,99,101,32,114,101,113,117,105,114,101,100,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,0,78,111,116,32,97,32,100,105,114,101,99,116,111,114,121,0,73,115,32,97,32,100,105,114,101,99,116,111,114,121,0,84,101,120,116,32,102,105,108,101,32,98,117,115,121,0,69,120,101,99,32,102,111,114,109,97,116,32,101,114,114,111,114,0,73,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,0,65,114,103,117,109,101,110,116,32,108,105,115,116,32,116,111,111,32,108,111,110,103,0,83,121,109,98,111,108,105,99,32,108,105,110,107,32,108,111,111,112,0,70,105,108,101,110,97,109,101,32,116,111,111,32,108,111,110,103,0,84,111,111,32,109,97,110,121,32,111,112,101,110,32,102,105,108,101,115,32,105,110,32,115,121,115,116,101,109,0,78,111,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,115,32,97,118,97,105,108,97,98,108,101,0,66,97,100,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,0,78,111,32,99,104,105,108,100,32,112,114,111,99,101,115,115,0,66,97,100,32,97,100,100,114,101,115,115,0,70,105,108,101,32,116,111,111,32,108,97,114,103,101,0,84,111,111,32,109,97,110,121,32,108,105,110,107,115,0,78,111,32,108,111,99,107,115,32,97,118,97,105,108,97,98,108,101,0,82,101,115,111,117,114,99,101,32,100,101,97,100,108,111,99,107,32,119,111,117,108,100,32,111,99,99,117,114,0,83,116,97,116,101,32,110,111,116,32,114,101,99,111,118,101,114,97,98,108,101,0,80,114,101,118,105,111,117,115,32,111,119,110,101,114,32,100,105,101,100,0,79,112,101,114,97,116,105,111,110,32,99,97,110,99,101,108,101,100,0,70,117,110,99,116,105,111,110,32,110,111,116,32,105,109,112,108,101,109,101,110,116,101,100,0,78,111,32,109,101,115,115,97,103,101,32,111,102,32,100,101,115,105,114,101,100,32,116,121,112,101,0,73,100,101,110,116,105,102,105,101,114,32,114,101,109,111,118,101,100,0,68,101,118,105,99,101,32,110,111,116,32,97,32,115,116,114,101,97,109,0,78,111,32,100,97,116,97,32,97,118,97,105,108,97,98,108,101,0,68,101,118,105,99,101,32,116,105,109,101,111,117,116,0,79,117,116,32,111,102,32,115,116,114,101,97,109,115,32,114,101,115,111,117,114,99,101,115,0,76,105,110,107,32,104,97,115,32,98,101,101,110,32,115,101,118,101,114,101,100,0,80,114,111,116,111,99,111,108,32,101,114,114,111,114,0,66,97,100,32,109,101,115,115,97,103,101,0,70,105,108,101,32,100,101,115,99,114,105,112,116,111,114,32,105,110,32,98,97,100,32,115,116,97,116,101,0,78,111,116,32,97,32,115,111,99,107,101,116,0,68,101,115,116,105,110,97,116,105,111,110,32,97,100,100,114,101,115,115,32,114,101,113,117,105,114,101,100,0,77,101,115,115,97,103,101,32,116,111,111,32,108,97,114,103,101,0,80,114,111,116,111,99,111,108,32,119,114,111,110,103,32,116,121,112,101,32,102,111,114,32,115,111,99,107,101,116,0,80,114,111,116,111,99,111,108,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,80,114,111,116,111,99,111,108,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,83,111,99,107,101,116,32,116,121,112,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,78,111,116,32,115,117,112,112,111,114,116,101,100,0,80,114,111,116,111,99,111,108,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,65,100,100,114,101,115,115,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,98,121,32,112,114,111,116,111,99,111,108,0,65,100,100,114,101,115,115,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,78,101,116,119,111,114,107,32,105,115,32,100,111,119,110,0,78,101,116,119,111,114,107,32,117,110,114,101,97,99,104,97,98,108,101,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,110,101,116,119,111,114,107,0,67,111,110,110,101,99,116,105,111,110,32,97,98,111,114,116,101,100,0,78,111,32,98,117,102,102,101,114,32,115,112,97,99,101,32,97,118,97,105,108,97,98,108,101,0,83,111,99,107,101,116,32,105,115,32,99,111,110,110,101,99,116,101,100,0,83,111,99,107,101,116,32,110,111,116,32,99,111,110,110,101,99,116,101,100,0,67,97,110,110,111,116,32,115,101,110,100,32,97,102,116,101,114,32,115,111,99,107,101,116,32,115,104,117,116,100,111,119,110,0,79,112,101,114,97,116,105,111,110,32,97,108,114,101,97,100,121,32,105,110,32,112,114,111,103,114,101,115,115,0,79,112,101,114,97,116,105,111,110,32,105,110,32,112,114,111,103,114,101,115,115,0,83,116,97,108,101,32,102,105,108,101,32,104,97,110,100,108,101,0,82,101,109,111,116,101,32,73,47,79,32,101,114,114,111,114,0,81,117,111,116,97,32,101,120,99,101,101,100,101,100,0,78,111,32,109,101,100,105,117,109,32,102,111,117,110,100,0,87,114,111,110,103,32,109,101,100,105,117,109,32,116,121,112,101,0,78,111,32,101,114,114,111,114,32,105,110,102,111,114,109,97,116,105,111,110,0,0,105,110,102,105,110,105,116,121,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,255,255,255,255,255,255,255,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,255,255,255,255,255,255,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,1,2,4,7,3,6,5,0,114,119,97],"i8",ALLOC_NONE,Runtime.GLOBAL_BASE+10240);allocate([17,0,10,0,17,17,17,0,0,0,0,5,0,0,0,0,0,0,9,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,15,10,17,17,17,3,10,7,0,1,19,9,11,11,0,0,9,6,11,0,0,11,0,6,17,0,0,0,17,17,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,10,10,17,17,17,0,10,0,0,2,0,9,11,0,0,0,9,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,4,13,0,0,0,0,9,14,0,0,0,0,0,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,15,0,0,0,0,9,16,0,0,0,0,0,16,0,0,16,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,10,0,0,0,0,9,11,0,0,0,0,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,45,43,32,32,32,48,88,48,120,0,40,110,117,108,108,41,0,45,48,88,43,48,88,32,48,88,45,48,120,43,48,120,32,48,120,0,105,110,102,0,73,78,70,0,110,97,110,0,78,65,78,0,46,0],"i8",ALLOC_NONE,Runtime.GLOBAL_BASE+15945);var tempDoublePtr=Runtime.alignMemory(allocate(12,"i8",ALLOC_STATIC),8);assert(tempDoublePtr%8==0);function copyTempFloat(ptr){HEAP8[tempDoublePtr]=HEAP8[ptr];HEAP8[tempDoublePtr+1]=HEAP8[ptr+1];HEAP8[tempDoublePtr+2]=HEAP8[ptr+2];HEAP8[tempDoublePtr+3]=HEAP8[ptr+3]}function copyTempDouble(ptr){HEAP8[tempDoublePtr]=HEAP8[ptr];HEAP8[tempDoublePtr+1]=HEAP8[ptr+1];HEAP8[tempDoublePtr+2]=HEAP8[ptr+2];HEAP8[tempDoublePtr+3]=HEAP8[ptr+3];HEAP8[tempDoublePtr+4]=HEAP8[ptr+4];HEAP8[tempDoublePtr+5]=HEAP8[ptr+5];HEAP8[tempDoublePtr+6]=HEAP8[ptr+6];HEAP8[tempDoublePtr+7]=HEAP8[ptr+7]}function _atexit(func,arg){__ATEXIT__.unshift({func:func,arg:arg})}function ___cxa_atexit(){return _atexit.apply(null,arguments)}Module["_i64Subtract"]=_i64Subtract;function ___assert_fail(condition,filename,line,func){ABORT=true;throw"Assertion failed: "+Pointer_stringify(condition)+", at: "+[filename?Pointer_stringify(filename):"unknown filename",line,func?Pointer_stringify(func):"unknown function"]+" at "+stackTrace()}function embind_init_charCodes(){var codes=new Array(256);for(var i=0;i<256;++i){codes[i]=String.fromCharCode(i)}embind_charCodes=codes}var embind_charCodes=undefined;function readLatin1String(ptr){var ret="";var c=ptr;while(HEAPU8[c]){ret+=embind_charCodes[HEAPU8[c++]]}return ret}var awaitingDependencies={};var registeredTypes={};var typeDependencies={};var char_0=48;var char_9=57;function makeLegalFunctionName(name){if(undefined===name){return"_unknown"}name=name.replace(/[^a-zA-Z0-9_]/g,"$");var f=name.charCodeAt(0);if(f>=char_0&&f<=char_9){return"_"+name}else{return name}}function createNamedFunction(name,body){name=makeLegalFunctionName(name);return new Function("body","return function "+name+"() {\n"+' "use strict";'+" return body.apply(this, arguments);\n"+"};\n")(body)}function extendError(baseErrorType,errorName){var errorClass=createNamedFunction(errorName,function(message){this.name=errorName;this.message=message;var stack=new Error(message).stack;if(stack!==undefined){this.stack=this.toString()+"\n"+stack.replace(/^Error(:[^\n]*)?\n/,"")}});errorClass.prototype=Object.create(baseErrorType.prototype);errorClass.prototype.constructor=errorClass;errorClass.prototype.toString=function(){if(this.message===undefined){return this.name}else{return this.name+": "+this.message}};return errorClass}var BindingError=undefined;function throwBindingError(message){throw new BindingError(message)}var InternalError=undefined;function throwInternalError(message){throw new InternalError(message)}function whenDependentTypesAreResolved(myTypes,dependentTypes,getTypeConverters){myTypes.forEach(function(type){typeDependencies[type]=dependentTypes});function onComplete(typeConverters){var myTypeConverters=getTypeConverters(typeConverters);if(myTypeConverters.length!==myTypes.length){throwInternalError("Mismatched type converter count")}for(var i=0;i0);info.refcount--;if(info.refcount===0){if(info.destructor){Runtime.dynCall("vi",info.destructor,[ptr])}delete EXCEPTIONS.infos[ptr];___cxa_free_exception(ptr)}},clearRef:function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount=0}};function ___resumeException(ptr){if(!EXCEPTIONS.last){EXCEPTIONS.last=ptr}EXCEPTIONS.clearRef(EXCEPTIONS.deAdjust(ptr));throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}function ___cxa_find_matching_catch(){var thrown=EXCEPTIONS.last;if(!thrown){return(asm["setTempRet0"](0),0)|0}var info=EXCEPTIONS.infos[thrown];var throwntype=info.type;if(!throwntype){return(asm["setTempRet0"](0),thrown)|0}var typeArray=Array.prototype.slice.call(arguments);var pointer=Module["___cxa_is_pointer_type"](throwntype);if(!___cxa_find_matching_catch.buffer)___cxa_find_matching_catch.buffer=_malloc(4);HEAP32[___cxa_find_matching_catch.buffer>>2]=thrown;thrown=___cxa_find_matching_catch.buffer;for(var i=0;i>2];info.adjusted=thrown;return(asm["setTempRet0"](typeArray[i]),thrown)|0}}thrown=HEAP32[thrown>>2];return(asm["setTempRet0"](throwntype),thrown)|0}function ___cxa_throw(ptr,type,destructor){EXCEPTIONS.infos[ptr]={ptr:ptr,adjusted:ptr,type:type,destructor:destructor,refcount:0};EXCEPTIONS.last=ptr;if(!("uncaught_exception"in __ZSt18uncaught_exceptionv)){__ZSt18uncaught_exceptionv.uncaught_exception=1}else{__ZSt18uncaught_exceptionv.uncaught_exception++}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}Module["_memset"]=_memset;var _BDtoILow=true;function getShiftFromSize(size){switch(size){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+size)}}function __embind_register_bool(rawType,name,size,trueValue,falseValue){var shift=getShiftFromSize(size);name=readLatin1String(name);registerType(rawType,{name:name,fromWireType:function(wt){return!!wt},toWireType:function(destructors,o){return o?trueValue:falseValue},argPackAdvance:8,readValueFromPointer:function(pointer){var heap;if(size===1){heap=HEAP8}else if(size===2){heap=HEAP16}else if(size===4){heap=HEAP32}else{throw new TypeError("Unknown boolean type size: "+name)}return this["fromWireType"](heap[pointer>>shift])},destructorFunction:null})}Module["_bitshift64Shl"]=_bitshift64Shl;function _abort(){Module["abort"]()}function _free(){}Module["_free"]=_free;function _malloc(bytes){var ptr=Runtime.dynamicAlloc(bytes+8);return ptr+8&4294967288}Module["_malloc"]=_malloc;function simpleReadValueFromPointer(pointer){return this["fromWireType"](HEAPU32[pointer>>2])}function __embind_register_std_string(rawType,name){name=readLatin1String(name);registerType(rawType,{name:name,fromWireType:function(value){var length=HEAPU32[value>>2];var a=new Array(length);for(var i=0;i>2]=length;for(var i=0;i255){_free(ptr);throwBindingError("String has UTF-16 code units that do not fit in 8 bits")}HEAPU8[ptr+4+i]=charCode}if(destructors!==null){destructors.push(_free,ptr)}return ptr},argPackAdvance:8,readValueFromPointer:simpleReadValueFromPointer,destructorFunction:function(ptr){_free(ptr)}})}function __embind_register_std_wstring(rawType,charSize,name){name=readLatin1String(name);var getHeap,shift;if(charSize===2){getHeap=function(){return HEAPU16};shift=1}else if(charSize===4){getHeap=function(){return HEAPU32};shift=2}registerType(rawType,{name:name,fromWireType:function(value){var HEAP=getHeap();var length=HEAPU32[value>>2];var a=new Array(length);var start=value+4>>shift;for(var i=0;i>2]=length;var start=ptr+4>>shift;for(var i=0;i>1]}:function readU16FromPointer(pointer){return HEAPU16[pointer>>1]};case 2:return signed?function readS32FromPointer(pointer){return HEAP32[pointer>>2]}:function readU32FromPointer(pointer){return HEAPU32[pointer>>2]};default:throw new TypeError("Unknown integer type: "+name)}}function __embind_register_integer(primitiveType,name,size,minRange,maxRange){name=readLatin1String(name);if(maxRange===-1){maxRange=4294967295}var shift=getShiftFromSize(size);var fromWireType=function(value){return value};if(minRange===0){var bitshift=32-8*size;fromWireType=function(value){return value<>>bitshift}}registerType(primitiveType,{name:name,fromWireType:fromWireType,toWireType:function(destructors,value){if(typeof value!=="number"&&typeof value!=="boolean"){throw new TypeError('Cannot convert "'+_embind_repr(value)+'" to '+this.name)}if(valuemaxRange){throw new TypeError('Passing a number "'+_embind_repr(value)+'" from JS side to C/C++ side to an argument of type "'+name+'", which is outside the valid range ['+minRange+", "+maxRange+"]!")}return value|0},argPackAdvance:8,readValueFromPointer:integerReadValueFromPointer(name,shift,minRange!==0),destructorFunction:null})}var emval_free_list=[];var emval_handle_array=[{},{value:undefined},{value:null},{value:true},{value:false}];function __emval_decref(handle){if(handle>4&&0===--emval_handle_array[handle].refcount){emval_handle_array[handle]=undefined;emval_free_list.push(handle)}}function count_emval_handles(){var count=0;for(var i=5;i>2]=value;return value}var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96, ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};function _sysconf(name){switch(name){case 30:return PAGE_SIZE;case 85:return totalMemory/PAGE_SIZE;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:{if(typeof navigator==="object")return navigator["hardwareConcurrency"]||1;return 1}}___setErrNo(ERRNO_CODES.EINVAL);return-1}Module["_bitshift64Lshr"]=_bitshift64Lshr;function __exit(status){Module["exit"](status)}function _exit(status){__exit(status)}var _llvm_ctlz_i32=true;function floatReadValueFromPointer(name,shift){switch(shift){case 2:return function(pointer){return this["fromWireType"](HEAPF32[pointer>>2])};case 3:return function(pointer){return this["fromWireType"](HEAPF64[pointer>>3])};default:throw new TypeError("Unknown float type: "+name)}}function __embind_register_float(rawType,name,size){var shift=getShiftFromSize(size);name=readLatin1String(name);registerType(rawType,{name:name,fromWireType:function(value){return value},toWireType:function(destructors,value){if(typeof value!=="number"&&typeof value!=="boolean"){throw new TypeError('Cannot convert "'+_embind_repr(value)+'" to '+this.name)}return value},argPackAdvance:8,readValueFromPointer:floatReadValueFromPointer(name,shift),destructorFunction:null})}var _BDtoIHigh=true;function _pthread_cleanup_push(routine,arg){__ATEXIT__.push(function(){Runtime.dynCall("vi",routine,[arg])});_pthread_cleanup_push.level=__ATEXIT__.length}function new_(constructor,argumentList){if(!(constructor instanceof Function)){throw new TypeError("new_ called with constructor type "+typeof constructor+" which is not a function")}var dummy=createNamedFunction(constructor.name||"unknownFunctionName",function(){});dummy.prototype=constructor.prototype;var obj=new dummy;var r=constructor.apply(obj,argumentList);return r instanceof Object?r:obj}function runDestructors(destructors){while(destructors.length){var ptr=destructors.pop();var del=destructors.pop();del(ptr)}}function craftInvokerFunction(humanName,argTypes,classType,cppInvokerFunc,cppTargetFunc){var argCount=argTypes.length;if(argCount<2){throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!")}var isClassMethodFunc=argTypes[1]!==null&&classType!==null;var argsList="";var argsListWired="";for(var i=0;i0?", ":"")+argsListWired}var returns=argTypes[0].name!=="void";invokerFnBody+=(returns?"var rv = ":"")+"invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";if(needsDestructorStack){invokerFnBody+="runDestructors(destructors);\n"}else{for(var i=isClassMethodFunc?1:2;i>2)+i])}return array}function replacePublicSymbol(name,value,numArguments){if(!Module.hasOwnProperty(name)){throwInternalError("Replacing nonexistant public symbol")}if(undefined!==Module[name].overloadTable&&undefined!==numArguments){Module[name].overloadTable[numArguments]=value}else{Module[name]=value}}function requireFunction(signature,rawFunction){signature=readLatin1String(signature);function makeDynCaller(dynCall){var args=[];for(var i=1;i=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up--;up){parts.unshift("..")}}return parts},normalize:function(path){var isAbsolute=path.charAt(0)==="/",trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter(function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path},dirname:function(path){var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir},basename:function(path){if(path==="/")return"/";var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)},extname:function(path){return PATH.splitPath(path)[3]},join:function(){var paths=Array.prototype.slice.call(arguments,0);return PATH.normalize(paths.join("/"))},join2:function(l,r){return PATH.normalize(l+"/"+r)},resolve:function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:FS.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){return""}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=PATH.normalizeArray(resolvedPath.split("/").filter(function(p){return!!p}),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."},relative:function(from,to){from=PATH.resolve(from).substr(1);to=PATH.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i0){result=buf.slice(0,bytesRead).toString("utf-8")}else{result=null}}else if(typeof window!="undefined"&&typeof window.prompt=="function"){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else if(typeof readline=="function"){result=readline();if(result!==null){result+="\n"}}if(!result){return null}tty.input=intArrayFromString(result,true)}return tty.input.shift()},put_char:function(tty,val){if(val===null||val===10){Module["print"](UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},flush:function(tty){if(tty.output&&tty.output.length>0){Module["print"](UTF8ArrayToString(tty.output,0));tty.output=[]}}},default_tty1_ops:{put_char:function(tty,val){if(val===null||val===10){Module["printErr"](UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},flush:function(tty){if(tty.output&&tty.output.length>0){Module["printErr"](UTF8ArrayToString(tty.output,0));tty.output=[]}}}};var MEMFS={ops_table:null,mount:function(mount){return MEMFS.createNode(null,"/",16384|511,0)},createNode:function(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(!MEMFS.ops_table){MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}}}var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.timestamp=Date.now();if(parent){parent.contents[name]=node}return node},getFileDataAsRegularArray:function(node){if(node.contents&&node.contents.subarray){var arr=[];for(var i=0;inode.contents.length){node.contents=MEMFS.getFileDataAsRegularArray(node);node.usedBytes=node.contents.length}if(!node.contents||node.contents.subarray){var prevCapacity=node.contents?node.contents.buffer.byteLength:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity0)node.contents.set(oldContents.subarray(0,node.usedBytes),0);return}if(!node.contents&&newCapacity>0)node.contents=[];while(node.contents.lengthnewSize)node.contents.length=newSize;else while(node.contents.length=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);assert(size>=0);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i0||position+lengthe2.timestamp){create.push(key);total++}});var remove=[];Object.keys(dst.entries).forEach(function(key){var e=dst.entries[key];var e2=src.entries[key];if(!e2){remove.push(key);total++}});if(!total){return callback(null)}var errored=false;var completed=0;var db=src.type==="remote"?src.db:dst.db;var transaction=db.transaction([IDBFS.DB_STORE_NAME],"readwrite");var store=transaction.objectStore(IDBFS.DB_STORE_NAME);function done(err){if(err){if(!done.errored){done.errored=true;return callback(err)}return}if(++completed>=total){return callback(null)}}transaction.onerror=function(e){done(this.error);e.preventDefault()};create.sort().forEach(function(path){if(dst.type==="local"){IDBFS.loadRemoteEntry(store,path,function(err,entry){if(err)return done(err);IDBFS.storeLocalEntry(path,entry,done)})}else{IDBFS.loadLocalEntry(path,function(err,entry){if(err)return done(err);IDBFS.storeRemoteEntry(store,path,entry,done)})}});remove.sort().reverse().forEach(function(path){if(dst.type==="local"){IDBFS.removeLocalEntry(path,done)}else{IDBFS.removeRemoteEntry(store,path,done)}})}};var NODEFS={isWindows:false,staticInit:function(){NODEFS.isWindows=!!process.platform.match(/^win/)},mount:function(mount){assert(ENVIRONMENT_IS_NODE);return NODEFS.createNode(null,"/",NODEFS.getMode(mount.opts.root),0)},createNode:function(parent,name,mode,dev){if(!FS.isDir(mode)&&!FS.isFile(mode)&&!FS.isLink(mode)){ throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var node=FS.createNode(parent,name,mode);node.node_ops=NODEFS.node_ops;node.stream_ops=NODEFS.stream_ops;return node},getMode:function(path){var stat;try{stat=fs.lstatSync(path);if(NODEFS.isWindows){stat.mode=stat.mode|(stat.mode&146)>>1}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}return stat.mode},realPath:function(node){var parts=[];while(node.parent!==node){parts.push(node.name);node=node.parent}parts.push(node.mount.opts.root);parts.reverse();return PATH.join.apply(null,parts)},flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function(flags){flags&=~32768;if(flags in NODEFS.flagsToPermissionStringMap){return NODEFS.flagsToPermissionStringMap[flags]}else{throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}},node_ops:{getattr:function(node){var path=NODEFS.realPath(node);var stat;try{stat=fs.lstatSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}if(NODEFS.isWindows&&!stat.blksize){stat.blksize=4096}if(NODEFS.isWindows&&!stat.blocks){stat.blocks=(stat.size+stat.blksize-1)/stat.blksize|0}return{dev:stat.dev,ino:stat.ino,mode:stat.mode,nlink:stat.nlink,uid:stat.uid,gid:stat.gid,rdev:stat.rdev,size:stat.size,atime:stat.atime,mtime:stat.mtime,ctime:stat.ctime,blksize:stat.blksize,blocks:stat.blocks}},setattr:function(node,attr){var path=NODEFS.realPath(node);try{if(attr.mode!==undefined){fs.chmodSync(path,attr.mode);node.mode=attr.mode}if(attr.timestamp!==undefined){var date=new Date(attr.timestamp);fs.utimesSync(path,date,date)}if(attr.size!==undefined){fs.truncateSync(path,attr.size)}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}},lookup:function(parent,name){var path=PATH.join2(NODEFS.realPath(parent),name);var mode=NODEFS.getMode(path);return NODEFS.createNode(parent,name,mode)},mknod:function(parent,name,mode,dev){var node=NODEFS.createNode(parent,name,mode,dev);var path=NODEFS.realPath(node);try{if(FS.isDir(node.mode)){fs.mkdirSync(path,node.mode)}else{fs.writeFileSync(path,"",{mode:node.mode})}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}return node},rename:function(oldNode,newDir,newName){var oldPath=NODEFS.realPath(oldNode);var newPath=PATH.join2(NODEFS.realPath(newDir),newName);try{fs.renameSync(oldPath,newPath)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}},unlink:function(parent,name){var path=PATH.join2(NODEFS.realPath(parent),name);try{fs.unlinkSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}},rmdir:function(parent,name){var path=PATH.join2(NODEFS.realPath(parent),name);try{fs.rmdirSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}},readdir:function(node){var path=NODEFS.realPath(node);try{return fs.readdirSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}},symlink:function(parent,newName,oldPath){var newPath=PATH.join2(NODEFS.realPath(parent),newName);try{fs.symlinkSync(oldPath,newPath)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}},readlink:function(node){var path=NODEFS.realPath(node);try{path=fs.readlinkSync(path);path=NODEJS_PATH.relative(NODEJS_PATH.resolve(node.mount.opts.root),path);return path}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}},stream_ops:{open:function(stream){var path=NODEFS.realPath(stream.node);try{if(FS.isFile(stream.node.mode)){stream.nfd=fs.openSync(path,NODEFS.flagsToPermissionString(stream.flags))}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}},close:function(stream){try{if(FS.isFile(stream.node.mode)&&stream.nfd){fs.closeSync(stream.nfd)}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}},read:function(stream,buffer,offset,length,position){if(length===0)return 0;var nbuffer=new Buffer(length);var res;try{res=fs.readSync(stream.nfd,nbuffer,0,length,position)}catch(e){throw new FS.ErrnoError(ERRNO_CODES[e.code])}if(res>0){for(var i=0;i=stream.node.size)return 0;var chunk=stream.node.contents.slice(position,position+length);var ab=WORKERFS.reader.readAsArrayBuffer(chunk);buffer.set(new Uint8Array(ab),offset);return chunk.size},write:function(stream,buffer,offset,length,position){throw new FS.ErrnoError(ERRNO_CODES.EIO)},llseek:function(stream,offset,whence){var position=offset;if(whence===1){position+=stream.position}else if(whence===2){if(FS.isFile(stream.node.mode)){position+=stream.node.size}}if(position<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}return position}}};var _stdin=allocate(1,"i32*",ALLOC_STATIC);var _stdout=allocate(1,"i32*",ALLOC_STATIC);var _stderr=allocate(1,"i32*",ALLOC_STATIC);var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},filesystems:null,handleFSError:function(e){if(!(e instanceof FS.ErrnoError))throw e+" : "+stackTrace();return ___setErrNo(e.errno)},lookupPath:function(path,opts){path=PATH.resolve(FS.cwd(),path);opts=opts||{};if(!path)return{path:"",node:null};var defaults={follow_mount:true,recurse_count:0};for(var key in defaults){if(opts[key]===undefined){opts[key]=defaults[key]}}if(opts.recurse_count>8){throw new FS.ErrnoError(ERRNO_CODES.ELOOP)}var parts=PATH.normalizeArray(path.split("/").filter(function(p){return!!p}),false);var current=FS.root;var current_path="/";for(var i=0;i40){throw new FS.ErrnoError(ERRNO_CODES.ELOOP)}}}}return{path:current_path,node:current}},getPath:function(node){var path;while(true){if(FS.isRoot(node)){var mount=node.mount.mountpoint;if(!path)return mount;return mount[mount.length-1]!=="/"?mount+"/"+path:mount+path}path=path?node.name+"/"+path:node.name;node=node.parent}},hashName:function(parentid,name){var hash=0;for(var i=0;i>>0)%FS.nameTable.length},hashAddNode:function(node){var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node},hashRemoveNode:function(node){var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}},lookupNode:function(parent,name){var err=FS.mayLookup(parent);if(err){throw new FS.ErrnoError(err,parent)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)},createNode:function(parent,name,mode,rdev){if(!FS.FSNode){FS.FSNode=function(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.mounted=null;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.node_ops={};this.stream_ops={};this.rdev=rdev};FS.FSNode.prototype={};var readMode=292|73;var writeMode=146;Object.defineProperties(FS.FSNode.prototype,{read:{get:function(){return(this.mode&readMode)===readMode},set:function(val){val?this.mode|=readMode:this.mode&=~readMode}},write:{get:function(){return(this.mode&writeMode)===writeMode},set:function(val){val?this.mode|=writeMode:this.mode&=~writeMode}},isFolder:{get:function(){return FS.isDir(this.mode)}},isDevice:{get:function(){return FS.isChrdev(this.mode)}}})}var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node},destroyNode:function(node){FS.hashRemoveNode(node)},isRoot:function(node){return node===node.parent},isMountpoint:function(node){return!!node.mounted},isFile:function(mode){return(mode&61440)===32768},isDir:function(mode){return(mode&61440)===16384},isLink:function(mode){return(mode&61440)===40960},isChrdev:function(mode){return(mode&61440)===8192},isBlkdev:function(mode){return(mode&61440)===24576},isFIFO:function(mode){return(mode&61440)===4096},isSocket:function(mode){return(mode&49152)===49152},flagModes:{r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function(str){var flags=FS.flagModes[str];if(typeof flags==="undefined"){throw new Error("Unknown file open mode: "+str)}return flags},flagsToPermissionString:function(flag){var perms=["r","w","rw"][flag&3];if(flag&512){perms+="w"}return perms},nodePermissions:function(node,perms){if(FS.ignorePermissions){return 0}if(perms.indexOf("r")!==-1&&!(node.mode&292)){return ERRNO_CODES.EACCES}else if(perms.indexOf("w")!==-1&&!(node.mode&146)){return ERRNO_CODES.EACCES}else if(perms.indexOf("x")!==-1&&!(node.mode&73)){return ERRNO_CODES.EACCES}return 0},mayLookup:function(dir){var err=FS.nodePermissions(dir,"x");if(err)return err;if(!dir.node_ops.lookup)return ERRNO_CODES.EACCES;return 0},mayCreate:function(dir,name){try{var node=FS.lookupNode(dir,name);return ERRNO_CODES.EEXIST}catch(e){}return FS.nodePermissions(dir,"wx")},mayDelete:function(dir,name,isdir){var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var err=FS.nodePermissions(dir,"wx");if(err){return err}if(isdir){if(!FS.isDir(node.mode)){return ERRNO_CODES.ENOTDIR}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return ERRNO_CODES.EBUSY}}else{if(FS.isDir(node.mode)){return ERRNO_CODES.EISDIR}}return 0},mayOpen:function(node,flags){if(!node){return ERRNO_CODES.ENOENT}if(FS.isLink(node.mode)){return ERRNO_CODES.ELOOP}else if(FS.isDir(node.mode)){if((flags&2097155)!==0||flags&512){return ERRNO_CODES.EISDIR}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))},MAX_OPEN_FDS:4096,nextfd:function(fd_start,fd_end){fd_start=fd_start||0;fd_end=fd_end||FS.MAX_OPEN_FDS;for(var fd=fd_start;fd<=fd_end;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(ERRNO_CODES.EMFILE)},getStream:function(fd){return FS.streams[fd]},createStream:function(stream,fd_start,fd_end){if(!FS.FSStream){FS.FSStream=function(){};FS.FSStream.prototype={};Object.defineProperties(FS.FSStream.prototype,{object:{get:function(){return this.node},set:function(val){this.node=val}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}}})}var newStream=new FS.FSStream;for(var p in stream){newStream[p]=stream[p]}stream=newStream;var fd=FS.nextfd(fd_start,fd_end);stream.fd=fd;FS.streams[fd]=stream;return stream},closeStream:function(fd){FS.streams[fd]=null},chrdev_stream_ops:{open:function(stream){var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;if(stream.stream_ops.open){stream.stream_ops.open(stream)}},llseek:function(){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE)}},major:function(dev){return dev>>8},minor:function(dev){return dev&255},makedev:function(ma,mi){return ma<<8|mi},registerDevice:function(dev,ops){FS.devices[dev]={stream_ops:ops}},getDevice:function(dev){return FS.devices[dev]},getMounts:function(mount){var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push.apply(check,m.mounts)}return mounts},syncfs:function(populate,callback){if(typeof populate==="function"){callback=populate;populate=false}var mounts=FS.getMounts(FS.root.mount);var completed=0;function done(err){if(err){if(!done.errored){done.errored=true;return callback(err)}return}if(++completed>=mounts.length){callback(null)}}mounts.forEach(function(mount){if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)})},mount:function(type,opts,mountpoint){var root=mountpoint==="/";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR)}}var mount={type:type,opts:opts,mountpoint:mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot},unmount:function(mountpoint){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach(function(hash){var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.indexOf(current.mount)!==-1){FS.destroyNode(current)}current=next}});node.mounted=null;var idx=node.mount.mounts.indexOf(mount);assert(idx!==-1);node.mount.mounts.splice(idx,1)},lookup:function(parent,name){return parent.node_ops.lookup(parent,name)},mknod:function(path,mode,dev){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name||name==="."||name===".."){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var err=FS.mayCreate(parent,name);if(err){throw new FS.ErrnoError(err)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}return parent.node_ops.mknod(parent,name,mode,dev)},create:function(path,mode){mode=mode!==undefined?mode:438;mode&=4095;mode|=32768;return FS.mknod(path,mode,0)},mkdir:function(path,mode){mode=mode!==undefined?mode:511;mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)},mkdev:function(path,mode,dev){if(typeof dev==="undefined"){dev=mode;mode=438}mode|=8192;return FS.mknod(path,mode,dev)},symlink:function(oldpath,newpath){if(!PATH.resolve(oldpath)){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}var lookup=FS.lookupPath(newpath,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}var newname=PATH.basename(newpath);var err=FS.mayCreate(parent,newname);if(err){throw new FS.ErrnoError(err)}if(!parent.node_ops.symlink){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}return parent.node_ops.symlink(parent,newname,oldpath)},rename:function(old_path,new_path){var old_dirname=PATH.dirname(old_path);var new_dirname=PATH.dirname(new_path);var old_name=PATH.basename(old_path);var new_name=PATH.basename(new_path);var lookup,old_dir,new_dir;try{lookup=FS.lookupPath(old_path,{parent:true});old_dir=lookup.node;lookup=FS.lookupPath(new_path,{parent:true});new_dir=lookup.node}catch(e){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}if(!old_dir||!new_dir)throw new FS.ErrnoError(ERRNO_CODES.ENOENT);if(old_dir.mount!==new_dir.mount){throw new FS.ErrnoError(ERRNO_CODES.EXDEV)}var old_node=FS.lookupNode(old_dir,old_name);var relative=PATH.relative(old_path,new_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}relative=PATH.relative(new_path,old_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY)}var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(old_node===new_node){return}var isdir=FS.isDir(old_node.mode);var err=FS.mayDelete(old_dir,old_name,isdir);if(err){throw new FS.ErrnoError(err)}err=new_node?FS.mayDelete(new_dir,new_name,isdir):FS.mayCreate(new_dir,new_name);if(err){throw new FS.ErrnoError(err)}if(!old_dir.node_ops.rename){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(FS.isMountpoint(old_node)||new_node&&FS.isMountpoint(new_node)){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}if(new_dir!==old_dir){err=FS.nodePermissions(old_dir,"w");if(err){throw new FS.ErrnoError(err)}}try{if(FS.trackingDelegate["willMovePath"]){FS.trackingDelegate["willMovePath"](old_path,new_path)}}catch(e){console.log("FS.trackingDelegate['willMovePath']('"+old_path+"', '"+new_path+"') threw an exception: "+e.message)}FS.hashRemoveNode(old_node);try{old_dir.node_ops.rename(old_node,new_dir,new_name)}catch(e){throw e}finally{FS.hashAddNode(old_node)}try{if(FS.trackingDelegate["onMovePath"])FS.trackingDelegate["onMovePath"](old_path,new_path)}catch(e){console.log("FS.trackingDelegate['onMovePath']('"+old_path+"', '"+new_path+"') threw an exception: "+e.message)}},rmdir:function(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var err=FS.mayDelete(parent,name,true);if(err){throw new FS.ErrnoError(err)}if(!parent.node_ops.rmdir){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}try{if(FS.trackingDelegate["willDeletePath"]){FS.trackingDelegate["willDeletePath"](path)}}catch(e){console.log("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: "+e.message)}parent.node_ops.rmdir(parent,name);FS.destroyNode(node);try{if(FS.trackingDelegate["onDeletePath"])FS.trackingDelegate["onDeletePath"](path)}catch(e){console.log("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: "+e.message)}},readdir:function(path){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;if(!node.node_ops.readdir){throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR)}return node.node_ops.readdir(node)},unlink:function(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var err=FS.mayDelete(parent,name,false);if(err){if(err===ERRNO_CODES.EISDIR)err=ERRNO_CODES.EPERM;throw new FS.ErrnoError(err)}if(!parent.node_ops.unlink){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}try{if(FS.trackingDelegate["willDeletePath"]){FS.trackingDelegate["willDeletePath"](path)}}catch(e){console.log("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: "+e.message)}parent.node_ops.unlink(parent,name);FS.destroyNode(node);try{if(FS.trackingDelegate["onDeletePath"])FS.trackingDelegate["onDeletePath"](path)}catch(e){console.log("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: "+e.message)}},readlink:function(path){var lookup=FS.lookupPath(path);var link=lookup.node;if(!link){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}if(!link.node_ops.readlink){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}return PATH.resolve(FS.getPath(link.parent),link.node_ops.readlink(link))},stat:function(path,dontFollow){var lookup=FS.lookupPath(path,{follow:!dontFollow});var node=lookup.node;if(!node){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}if(!node.node_ops.getattr){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}return node.node_ops.getattr(node)},lstat:function(path){return FS.stat(path,true)},chmod:function(path,mode,dontFollow){var node;if(typeof path==="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}node.node_ops.setattr(node,{mode:mode&4095|node.mode&~4095,timestamp:Date.now()})},lchmod:function(path,mode){FS.chmod(path,mode,true)},fchmod:function(fd,mode){var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}FS.chmod(stream.node,mode)},chown:function(path,uid,gid,dontFollow){var node;if(typeof path==="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}node.node_ops.setattr(node,{timestamp:Date.now()})},lchown:function(path,uid,gid){FS.chown(path,uid,gid,true)},fchown:function(fd,uid,gid){var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}FS.chown(stream.node,uid,gid)},truncate:function(path,len){if(len<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var node;if(typeof path==="string"){var lookup=FS.lookupPath(path,{follow:true});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(FS.isDir(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.EISDIR)}if(!FS.isFile(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var err=FS.nodePermissions(node,"w");if(err){throw new FS.ErrnoError(err)}node.node_ops.setattr(node,{size:len,timestamp:Date.now()})},ftruncate:function(fd,len){var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}FS.truncate(stream.node,len)},utime:function(path,atime,mtime){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;node.node_ops.setattr(node,{timestamp:Math.max(atime,mtime)})},open:function(path,flags,mode,fd_start,fd_end){if(path===""){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}flags=typeof flags==="string"?FS.modeStringToFlags(flags):flags;mode=typeof mode==="undefined"?438:mode;if(flags&64){mode=mode&4095|32768}else{mode=0}var node;if(typeof path==="object"){node=path}else{path=PATH.normalize(path);try{var lookup=FS.lookupPath(path,{follow:!(flags&131072)});node=lookup.node}catch(e){}}var created=false;if(flags&64){if(node){if(flags&128){throw new FS.ErrnoError(ERRNO_CODES.EEXIST)}}else{node=FS.mknod(path,mode,0);created=true}}if(!node){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}if(FS.isChrdev(node.mode)){flags&=~512}if(flags&65536&&!FS.isDir(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR)}if(!created){var err=FS.mayOpen(node,flags);if(err){throw new FS.ErrnoError(err)}}if(flags&512){FS.truncate(node,0)}flags&=~(128|512);var stream=FS.createStream({node:node,path:FS.getPath(node),flags:flags,seekable:true,position:0,stream_ops:node.stream_ops,ungotten:[],error:false},fd_start,fd_end);if(stream.stream_ops.open){stream.stream_ops.open(stream)}if(Module["logReadFiles"]&&!(flags&1)){if(!FS.readFiles)FS.readFiles={};if(!(path in FS.readFiles)){FS.readFiles[path]=1;Module["printErr"]("read file: "+path)}}try{if(FS.trackingDelegate["onOpenFile"]){var trackingFlags=0;if((flags&2097155)!==1){trackingFlags|=FS.tracking.openFlags.READ}if((flags&2097155)!==0){trackingFlags|=FS.tracking.openFlags.WRITE}FS.trackingDelegate["onOpenFile"](path,trackingFlags)}}catch(e){console.log("FS.trackingDelegate['onOpenFile']('"+path+"', flags) threw an exception: "+e.message)}return stream},close:function(stream){if(stream.getdents)stream.getdents=null;try{if(stream.stream_ops.close){stream.stream_ops.close(stream)}}catch(e){throw e}finally{FS.closeStream(stream.fd)}},llseek:function(stream,offset,whence){if(!stream.seekable||!stream.stream_ops.llseek){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE)}stream.position=stream.stream_ops.llseek(stream,offset,whence);stream.ungotten=[];return stream.position},read:function(stream,buffer,offset,length,position){if(length<0||position<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(ERRNO_CODES.EISDIR)}if(!stream.stream_ops.read){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var seeking=true;if(typeof position==="undefined"){position=stream.position;seeking=false}else if(!stream.seekable){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE)}var bytesRead=stream.stream_ops.read(stream,buffer,offset,length,position);if(!seeking)stream.position+=bytesRead;return bytesRead},write:function(stream,buffer,offset,length,position,canOwn){if(length<0||position<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(ERRNO_CODES.EISDIR)}if(!stream.stream_ops.write){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}if(stream.flags&1024){FS.llseek(stream,0,2)}var seeking=true;if(typeof position==="undefined"){position=stream.position;seeking=false}else if(!stream.seekable){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE)}var bytesWritten=stream.stream_ops.write(stream,buffer,offset,length,position,canOwn);if(!seeking)stream.position+=bytesWritten;try{if(stream.path&&FS.trackingDelegate["onWriteToFile"])FS.trackingDelegate["onWriteToFile"](stream.path)}catch(e){console.log("FS.trackingDelegate['onWriteToFile']('"+path+"') threw an exception: "+e.message)}return bytesWritten},allocate:function(stream,offset,length){if(offset<0||length<=0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}if(!FS.isFile(stream.node.mode)&&!FS.isDir(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENODEV)}if(!stream.stream_ops.allocate){throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP)}stream.stream_ops.allocate(stream,offset,length)},mmap:function(stream,buffer,offset,length,position,prot,flags){if((stream.flags&2097155)===1){throw new FS.ErrnoError(ERRNO_CODES.EACCES)}if(!stream.stream_ops.mmap){throw new FS.ErrnoError(ERRNO_CODES.ENODEV)}return stream.stream_ops.mmap(stream,buffer,offset,length,position,prot,flags)},msync:function(stream,buffer,offset,length,mmapFlags){if(!stream||!stream.stream_ops.msync){return 0}return stream.stream_ops.msync(stream,buffer,offset,length,mmapFlags)},munmap:function(stream){return 0},ioctl:function(stream,cmd,arg){if(!stream.stream_ops.ioctl){throw new FS.ErrnoError(ERRNO_CODES.ENOTTY)}return stream.stream_ops.ioctl(stream,cmd,arg)},readFile:function(path,opts){opts=opts||{};opts.flags=opts.flags||"r";opts.encoding=opts.encoding||"binary";if(opts.encoding!=="utf8"&&opts.encoding!=="binary"){throw new Error('Invalid encoding type "'+opts.encoding+'"')}var ret;var stream=FS.open(path,opts.flags);var stat=FS.stat(path);var length=stat.size;var buf=new Uint8Array(length);FS.read(stream,buf,0,length,0);if(opts.encoding==="utf8"){ret=UTF8ArrayToString(buf,0)}else if(opts.encoding==="binary"){ret=buf}FS.close(stream);return ret},writeFile:function(path,data,opts){opts=opts||{};opts.flags=opts.flags||"w";opts.encoding=opts.encoding||"utf8";if(opts.encoding!=="utf8"&&opts.encoding!=="binary"){throw new Error('Invalid encoding type "'+opts.encoding+'"')}var stream=FS.open(path,opts.flags,opts.mode);if(opts.encoding==="utf8"){var buf=new Uint8Array(lengthBytesUTF8(data)+1);var actualNumBytes=stringToUTF8Array(data,buf,0,buf.length);FS.write(stream,buf,0,actualNumBytes,0,opts.canOwn)}else if(opts.encoding==="binary"){FS.write(stream,data,0,data.length,0,opts.canOwn)}FS.close(stream)},cwd:function(){return FS.currentPath},chdir:function(path){var lookup=FS.lookupPath(path,{follow:true});if(!FS.isDir(lookup.node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR)}var err=FS.nodePermissions(lookup.node,"x");if(err){throw new FS.ErrnoError(err)}FS.currentPath=lookup.path},createDefaultDirectories:function(){FS.mkdir("/tmp");FS.mkdir("/home");FS.mkdir("/home/web_user")},createDefaultDevices:function(){FS.mkdir("/dev");FS.registerDevice(FS.makedev(1,3),{read:function(){return 0},write:function(stream,buffer,offset,length,pos){return length}});FS.mkdev("/dev/null",FS.makedev(1,3));TTY.register(FS.makedev(5,0),TTY.default_tty_ops);TTY.register(FS.makedev(6,0),TTY.default_tty1_ops);FS.mkdev("/dev/tty",FS.makedev(5,0));FS.mkdev("/dev/tty1",FS.makedev(6,0));var random_device;if(typeof crypto!=="undefined"){var randomBuffer=new Uint8Array(1);random_device=function(){crypto.getRandomValues(randomBuffer);return randomBuffer[0]}}else if(ENVIRONMENT_IS_NODE){random_device=function(){return require("crypto").randomBytes(1)[0]}}else{random_device=function(){return Math.random()*256|0}}FS.createDevice("/dev","random",random_device);FS.createDevice("/dev","urandom",random_device);FS.mkdir("/dev/shm");FS.mkdir("/dev/shm/tmp")},createSpecialDirectories:function(){FS.mkdir("/proc");FS.mkdir("/proc/self");FS.mkdir("/proc/self/fd");FS.mount({mount:function(){var node=FS.createNode("/proc/self","fd",16384|511,73);node.node_ops={lookup:function(parent,name){var fd=+name;var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(ERRNO_CODES.EBADF);var ret={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:function(){return stream.path; diff --git a/aframe/examples/aframe-session.html b/aframe/examples/aframe-session.html index fbe709d..e80fbc1 100644 --- a/aframe/examples/aframe-session.html +++ b/aframe/examples/aframe-session.html @@ -62,17 +62,17 @@ - + @@ -87,11 +87,11 @@ --> - + diff --git a/three.js/build/ar.js b/three.js/build/ar.js index 31f15b2..beef94e 100644 --- a/three.js/build/ar.js +++ b/three.js/build/ar.js @@ -2389,9 +2389,10 @@ THREEx.ArSmoothedControls.prototype.update = function(targetObject3d){ object3d.scale.lerp(targetObject3d.scale, parameters.lerpScale) } } +var ARjs = ARjs || {} var THREEx = THREEx || {} -THREEx.ArToolkitContext = function(parameters){ +ARjs.Context = THREEx.ArToolkitContext = function(parameters){ var _this = this _this._updatedAt = null @@ -2408,7 +2409,7 @@ THREEx.ArToolkitContext = function(parameters){ matrixCodeType: '3x3', // url of the camera parameters - cameraParametersUrl: THREEx.ArToolkitContext.baseURL + 'parameters/camera_para.dat', + cameraParametersUrl: ARjs.Context.baseURL + 'parameters/camera_para.dat', // tune the maximum rate of pose detection in the source image maxDetectionRate: 60, @@ -2458,12 +2459,12 @@ THREEx.ArToolkitContext = function(parameters){ } } -Object.assign( THREEx.ArToolkitContext.prototype, THREE.EventDispatcher.prototype ); +Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype ); -// THREEx.ArToolkitContext.baseURL = '../' +// ARjs.Context.baseURL = '../' // default to github page -THREEx.ArToolkitContext.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/' -THREEx.ArToolkitContext.REVISION = '1.0.1-dev' +ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/' +ARjs.Context.REVISION = '1.0.1-dev' @@ -2472,7 +2473,7 @@ THREEx.ArToolkitContext.REVISION = '1.0.1-dev' * @param {string} trackingBackend - the tracking to user * @return {THREE.Camera} the created camera */ -THREEx.ArToolkitContext.createDefaultCamera = function( trackingBackend ){ +ARjs.Context.createDefaultCamera = function( trackingBackend ){ console.assert(false, 'use ARjs.Utils.createDefaultCamera instead') // Create a camera if( trackingBackend === 'artoolkit' ){ @@ -2489,7 +2490,7 @@ THREEx.ArToolkitContext.createDefaultCamera = function( trackingBackend ){ ////////////////////////////////////////////////////////////////////////////// // init functions ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype.init = function(onCompleted){ +ARjs.Context.prototype.init = function(onCompleted){ var _this = this if( this.parameters.trackingBackend === 'artoolkit' ){ this._initArtoolkit(done) @@ -2515,7 +2516,7 @@ THREEx.ArToolkitContext.prototype.init = function(onCompleted){ //////////////////////////////////////////////////////////////////////////////// // update function //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype.update = function(srcElement){ +ARjs.Context.prototype.update = function(srcElement){ // be sure arController is fully initialized if(this.parameters.trackingBackend === 'artoolkit' && this.arController === null) return false; @@ -2556,12 +2557,12 @@ THREEx.ArToolkitContext.prototype.update = function(srcElement){ //////////////////////////////////////////////////////////////////////////////// // Add/Remove markerControls //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype.addMarker = function(arMarkerControls){ +ARjs.Context.prototype.addMarker = function(arMarkerControls){ console.assert(arMarkerControls instanceof THREEx.ArMarkerControls) this._arMarkersControls.push(arMarkerControls) } -THREEx.ArToolkitContext.prototype.removeMarker = function(arMarkerControls){ +ARjs.Context.prototype.removeMarker = function(arMarkerControls){ console.assert(arMarkerControls instanceof THREEx.ArMarkerControls) // console.log('remove marker for', arMarkerControls) var index = this.arMarkerControlss.indexOf(artoolkitMarker); @@ -2572,7 +2573,7 @@ THREEx.ArToolkitContext.prototype.removeMarker = function(arMarkerControls){ ////////////////////////////////////////////////////////////////////////////// // artoolkit specific ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype._initArtoolkit = function(onCompleted){ +ARjs.Context.prototype._initArtoolkit = function(onCompleted){ var _this = this // set this._artoolkitProjectionAxisTransformMatrix to change artoolkit projection matrix axis to match usual webgl one @@ -2643,7 +2644,7 @@ THREEx.ArToolkitContext.prototype._initArtoolkit = function(onCompleted){ /** * return the projection matrix */ -THREEx.ArToolkitContext.prototype.getProjectionMatrix = function(srcElement){ +ARjs.Context.prototype.getProjectionMatrix = function(srcElement){ // FIXME rename this function to say it is artoolkit specific - getArtoolkitProjectMatrix @@ -2666,14 +2667,14 @@ THREEx.ArToolkitContext.prototype.getProjectionMatrix = function(srcElement){ return projectionMatrix } -THREEx.ArToolkitContext.prototype._updateArtoolkit = function(srcElement){ +ARjs.Context.prototype._updateArtoolkit = function(srcElement){ this.arController.process(srcElement) } ////////////////////////////////////////////////////////////////////////////// // aruco specific ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype._initAruco = function(onCompleted){ +ARjs.Context.prototype._initAruco = function(onCompleted){ this.arucoContext = new THREEx.ArucoContext() // honor this.parameters.canvasWidth/.canvasHeight @@ -2694,7 +2695,7 @@ THREEx.ArToolkitContext.prototype._initAruco = function(onCompleted){ } -THREEx.ArToolkitContext.prototype._updateAruco = function(srcElement){ +ARjs.Context.prototype._updateAruco = function(srcElement){ // console.log('update aruco here') var _this = this var arMarkersControls = this._arMarkersControls @@ -2722,7 +2723,7 @@ THREEx.ArToolkitContext.prototype._updateAruco = function(srcElement){ ////////////////////////////////////////////////////////////////////////////// // tango specific ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype._initTango = function(onCompleted){ +ARjs.Context.prototype._initTango = function(onCompleted){ var _this = this // check webvr is available if (navigator.getVRDisplays){ @@ -2765,7 +2766,7 @@ THREEx.ArToolkitContext.prototype._initTango = function(onCompleted){ } -THREEx.ArToolkitContext.prototype._updateTango = function(srcElement){ +ARjs.Context.prototype._updateTango = function(srcElement){ // console.log('update aruco here') var _this = this var arMarkersControls = this._arMarkersControls @@ -2818,7 +2819,6 @@ THREEx.ArToolkitContext.prototype._updateTango = function(srcElement){ } var ARjs = ARjs || {} - var THREEx = THREEx || {} /** @@ -2994,32 +2994,59 @@ ARjs.Profile.prototype.checkIfValid = function () { } return this } +var ARjs = ARjs || {} var THREEx = THREEx || {} -THREEx.ArToolkitSource = function(parameters){ +ARjs.Source = THREEx.ArToolkitSource = function(parameters){ + var _this = this + + this.ready = false + this.domElement = null + // handle default parameters this.parameters = { // type of source - ['webcam', 'image', 'video'] - sourceType : parameters.sourceType !== undefined ? parameters.sourceType : 'webcam', + sourceType : 'webcam', // url of the source - valid if sourceType = image|video - sourceUrl : parameters.sourceUrl !== undefined ? parameters.sourceUrl : null, + sourceUrl : null, // resolution of at which we initialize in the source image - sourceWidth: parameters.sourceWidth !== undefined ? parameters.sourceWidth : 640, - sourceHeight: parameters.sourceHeight !== undefined ? parameters.sourceHeight : 480, + sourceWidth: 640, + sourceHeight: 480, // resolution displayed for the source - displayWidth: parameters.displayWidth !== undefined ? parameters.displayWidth : 640, - displayHeight: parameters.displayHeight !== undefined ? parameters.displayHeight : 480, + displayWidth: 640, + displayHeight: 480, } + ////////////////////////////////////////////////////////////////////////////// + // setParameters + ////////////////////////////////////////////////////////////////////////////// + setParameters(parameters) + function setParameters(parameters){ + if( parameters === undefined ) return + for( var key in parameters ){ + var newValue = parameters[ key ] - this.ready = false - this.domElement = null + if( newValue === undefined ){ + console.warn( "THREEx.ArToolkitSource: '" + key + "' parameter is undefined." ) + continue + } + + var currentValue = _this.parameters[ key ] + + if( currentValue === undefined ){ + console.warn( "THREEx.ArToolkitSource: '" + key + "' is not a property of this material." ) + continue + } + + _this.parameters[ key ] = newValue + } + } } ////////////////////////////////////////////////////////////////////////////// // Code Separator ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.init = function(onReady, onError){ +ARjs.Source.prototype.init = function(onReady, onError){ var _this = this if( this.parameters.sourceType === 'image' ){ @@ -3055,7 +3082,7 @@ THREEx.ArToolkitSource.prototype.init = function(onReady, onError){ //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype._initSourceImage = function(onReady) { +ARjs.Source.prototype._initSourceImage = function(onReady) { // TODO make it static var domElement = document.createElement('img') domElement.src = this.parameters.sourceUrl @@ -3080,7 +3107,7 @@ THREEx.ArToolkitSource.prototype._initSourceImage = function(onReady) { //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype._initSourceVideo = function(onReady) { +ARjs.Source.prototype._initSourceVideo = function(onReady) { // TODO make it static var domElement = document.createElement('video'); domElement.src = this.parameters.sourceUrl @@ -3117,12 +3144,12 @@ THREEx.ArToolkitSource.prototype._initSourceVideo = function(onReady) { // handle webcam source //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype._initSourceWebcam = function(onReady, onError) { +ARjs.Source.prototype._initSourceWebcam = function(onReady, onError) { var _this = this -debugger + // init default value onError = onError || function(error){ - alert('Cant init webcam due to '+error.message) + alert('Webcam Error\nName: '+error.name + '\nMessage: '+error.message) } var domElement = document.createElement('video'); @@ -3132,13 +3159,18 @@ debugger domElement.style.width = this.parameters.displayWidth+'px' domElement.style.height = this.parameters.displayHeight+'px' + // check API is available if (navigator.mediaDevices === undefined || navigator.mediaDevices.enumerateDevices === undefined || navigator.mediaDevices.getUserMedia === undefined ){ - onError("WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser") + onError({ + name: '', + message: 'WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser' + }) return } + // get available devices navigator.mediaDevices.enumerateDevices().then(function(devices) { var userMediaConstraints = { audio: false, @@ -3156,6 +3188,7 @@ debugger } } } + // get a device which satisfy the constraints navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream) { // set the .src of the domElement domElement.srcObject = stream; @@ -3164,6 +3197,7 @@ debugger domElement.play(); }) // domElement.play(); + // TODO listen to loadedmetadata instead // wait until the video stream is ready var interval = setInterval(function() { @@ -3173,7 +3207,8 @@ debugger }, 1000/50); }).catch(function(error) { onError({ - message: "Can't access user media :()" + name: error.name, + message: error.message }); }); }).catch(function(error) { @@ -3188,7 +3223,7 @@ debugger ////////////////////////////////////////////////////////////////////////////// // Handle Mobile Torch ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.hasMobileTorch = function(){ +ARjs.Source.prototype.hasMobileTorch = function(){ var stream = arToolkitSource.domElement.srcObject if( stream instanceof MediaStream === false ) return false @@ -3210,7 +3245,7 @@ THREEx.ArToolkitSource.prototype.hasMobileTorch = function(){ * toggle the flash/torch of the mobile fun if applicable. * Great post about it https://www.oberhofer.co/mediastreamtrack-and-its-capabilities/ */ -THREEx.ArToolkitSource.prototype.toggleMobileTorch = function(){ +ARjs.Source.prototype.toggleMobileTorch = function(){ // sanity check console.assert(this.hasMobileTorch() === true) @@ -3246,7 +3281,7 @@ THREEx.ArToolkitSource.prototype.toggleMobileTorch = function(){ // handle resize //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.onResizeElement = function(mirrorDomElements){ +ARjs.Source.prototype.onResizeElement = function(mirrorDomElements){ var _this = this var screenWidth = window.innerWidth var screenHeight = window.innerHeight @@ -3304,7 +3339,7 @@ THREEx.ArToolkitSource.prototype.onResizeElement = function(mirrorDomElements){ }) } -THREEx.ArToolkitSource.prototype.copyElementSizeTo = function(otherElement){ +ARjs.Source.prototype.copyElementSizeTo = function(otherElement){ otherElement.style.width = this.domElement.style.width otherElement.style.height = this.domElement.style.height otherElement.style.marginLeft = this.domElement.style.marginLeft @@ -3315,7 +3350,7 @@ THREEx.ArToolkitSource.prototype.copyElementSizeTo = function(otherElement){ // Code Separator ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.copySizeTo = function(){ +ARjs.Source.prototype.copySizeTo = function(){ console.warn('obsolete function arToolkitSource.copySizeTo. Use arToolkitSource.copyElementSizeTo' ) this.copyElementSizeTo.apply(this, arguments) } @@ -3324,14 +3359,15 @@ THREEx.ArToolkitSource.prototype.copySizeTo = function(){ // Code Separator ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.onResize = function(arToolkitContext, renderer, camera){ - var trackingBackend = arToolkitContext.parameters.trackingBackend - +ARjs.Source.prototype.onResize = function(arToolkitContext, renderer, camera){ if( arguments.length !== 3 ){ console.warn('obsolete function arToolkitSource.onResize. Use arToolkitSource.onResizeElement' ) return this.onResizeElement.apply(this, arguments) } + var trackingBackend = arToolkitContext.parameters.trackingBackend + + // RESIZE DOMELEMENT if( trackingBackend === 'artoolkit' ){ diff --git a/three.js/build/ar.min.js b/three.js/build/ar.min.js index e14e7c6..c4c9f22 100644 --- a/three.js/build/ar.min.js +++ b/three.js/build/ar.min.js @@ -23,5 +23,5 @@ c[f+260>>2]=e;if((e|0)<0){c[g>>2]=d;Me(3,6312,g);Ce(c[b>>2]|0)|0;Me(3,6358,h);e= n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}else{b[e>>1]=0;a[l>>0]=0;j=r}while(0);t=t+1|0;n=s+2|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+4|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Dd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<1)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){p=d[s>>0]|0;q=d[s+1>>0]|0;do if(((p&248)+12+(p<<5&224)+(q>>>3&24)+(q<<2&248)|0)>(A|0)){a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}else{b[e>>1]=0;a[l>>0]=0;j=r}while(0);t=t+1|0;n=s+2|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+4|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Ed(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<2)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){do if(((d[s+2>>0]|0)+(d[s+1>>0]|0)+(d[s+3>>0]|0)|0)>(A|0)){a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}else{b[e>>1]=0;a[l>>0]=0;j=r}while(0);t=t+1|0;n=s+4|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+8|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Fd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;l=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;p=(c[k+4>>2]|0)+l|0;z=1;e=e+l|0;o=o+(l<<1)|0;m=0;b:while(1){if(y){l=p;u=1;t=e;s=m;while(1){do if((d[t>>0]|0|0)>(j|0)){a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}else{b[o>>1]=0;a[l>>0]=0;m=s}while(0);u=u+1|0;e=t+1|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}else l=p;z=z+1|0;if((z|0)>=(B|0)){q=m;D=52;break a}else{p=l+2|0;e=e+2|0;o=o+4|0}}Me(3,3904,C);l=-1}else{q=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((q|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(q|0)){e=e+1|0;n=n+4|0}else break}}p=k+8|0;l=m+-1|0;c[p>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[p>>2]|0))}if((q|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(q|0))}if((c[p>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[p>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Gd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;l=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;p=(c[k+4>>2]|0)+l|0;z=1;e=e+(l<<1)|0;o=o+(l<<1)|0;m=0;b:while(1){if(y){l=p;u=1;t=e;s=m;while(1){do if((d[t+1>>0]|0|0)>(j|0)){a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}else{b[o>>1]=0;a[l>>0]=0;m=s}while(0);u=u+1|0;e=t+2|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}else l=p;z=z+1|0;if((z|0)>=(B|0)){q=m;D=52;break a}else{p=l+2|0;e=e+4|0;o=o+4|0}}Me(3,3904,C);l=-1}else{q=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((q|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(q|0)){e=e+1|0;n=n+4|0}else break}}p=k+8|0;l=m+-1|0;c[p>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[p>>2]|0))}if((q|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(q|0))}if((c[p>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[p>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Hd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;l=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;p=(c[k+4>>2]|0)+l|0;z=1;e=e+(l<<1)|0;o=o+(l<<1)|0;m=0;b:while(1){if(y){l=p;u=1;t=e;s=m;while(1){do if((d[t>>0]|0|0)>(j|0)){a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}else{b[o>>1]=0;a[l>>0]=0;m=s}while(0);u=u+1|0;e=t+2|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}else l=p;z=z+1|0;if((z|0)>=(B|0)){q=m;D=52;break a}else{p=l+2|0;e=e+4|0;o=o+4|0}}Me(3,3904,C);l=-1}else{q=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((q|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(q|0)){e=e+1|0;n=n+4|0}else break}}p=k+8|0;l=m+-1|0;c[p>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[p>>2]|0))}if((q|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(q|0))}if((c[p>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[p>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Id(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;m=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;l=(c[k+4>>2]|0)+m|0;z=1;e=e+m|0;o=o+(m<<1)|0;j=j+m|0;m=0;b:while(1){if(y){u=1;t=e;s=m;while(1){do if((d[t>>0]|0)>(d[j>>0]|0)){a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}else{b[o>>1]=0;a[l>>0]=0;m=s}while(0);u=u+1|0;e=t+1|0;j=j+1|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}z=z+1|0;if((z|0)>=(B|0)){p=m;D=52;break a}else{l=l+2|0;e=e+2|0;o=o+4|0;j=j+2|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((p|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(p|0)){e=e+1|0;n=n+4|0}else break}}j=k+8|0;l=m+-1|0;c[j>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[j>>2]|0))}if((p|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(p|0))}if((c[j>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[j>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Jd(a){a=a|0;return Kd(a+8|0)|0}function Kd(a){a=a|0;var b=0,d=0;d=i;i=i+16|0;b=Uj(4)|0;if(!b){Me(3,5472,d);rb(1)}a=wf(a)|0;c[b>>2]=a;if(!a){Vj(b);b=0}i=d;return b|0}function Ld(a){a=a|0;var b=0;b=c[a>>2]|0;if(!b)b=-1;else{xf(b)|0;Vj(c[a>>2]|0);c[a>>2]=0;b=0}return b|0}function Md(a){a=a|0;var b=0,d=0,e=0;d=i;i=i+16|0;b=Uj(7062432)|0;if(!b){Me(3,5472,d);rb(1)}c[b>>2]=0;c[b+4834148>>2]=0;c[b+7062408>>2]=0;c[b+4>>2]=-1;c[b+8>>2]=0;c[b+12>>2]=1;c[b+16>>2]=100;c[b+20>>2]=0;c[b+24>>2]=0;c[b+28>>2]=2;h[b+7062416>>3]=.5;c[b+7062424>>2]=3;c[b+32>>2]=a;e=c[a>>2]|0;c[b+36>>2]=e;a=c[a+4>>2]|0;c[b+40>>2]=a;c[b+44>>2]=0;c[b+15408>>2]=0;c[b+4834152>>2]=0;c[b+4818296>>2]=0;a=Uj($(e<<1,a)|0)|0;c[b+4834144>>2]=a;if(!a){Me(3,5472,d+8|0);rb(1)}else{c[b+7062384>>2]=0;Nd(b,2)|0;Od(b,0)|0;c[b+7062388>>2]=-1;Pd(b,0)|0;c[b+7062392>>2]=7;c[b+7062396>>2]=0;i=d;return b|0}return 0}function Nd(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=i;i=i+16|0;d=g;a:do if(a){e=a+4|0;if((c[e>>2]|0)!=(b|0)){switch(b|0){case 11:case 10:case 9:case 8:case 7:case 6:case 4:case 3:case 2:case 1:case 0:{f=0;break}case 14:case 13:case 12:case 5:{f=1;break}default:{c[d>>2]=b;Me(3,3936,d);d=-1;break a}}c[e>>2]=b;c[a+8>>2]=Pe(b)|0;d=a+7062408|0;b=c[d>>2]|0;if(b){pe(b);c[d>>2]=oe(c[a+36>>2]|0,c[a+40>>2]|0,c[e>>2]|0,0)|0}d=a+24|0;b=c[d>>2]|0;if(!f)switch(b|0){case 1:{c[d>>2]=4;d=0;break a}case 4:{c[d>>2]=3;d=0;break a}default:{d=0;break a}}else switch(b|0){case 0:{c[d>>2]=1;d=0;break a}case 3:{c[d>>2]=4;d=0;break a}default:{d=0;break a}}}else d=0; }else d=-1;while(0);i=g;return d|0}function Od(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=i;i=i+16|0;e=f;do if(a)if((c[a>>2]|0)!=(b|0)){c[a>>2]=b;if(!b){d=a+4834148|0;Vj(c[d>>2]|0);c[d>>2]=0;d=0;break}b=Uj($(c[a+40>>2]|0,c[a+36>>2]|0)|0)|0;c[a+4834148>>2]=b;if(!b){Me(3,5472,e);rb(1)}else d=0}else d=0;else d=-1;while(0);i=f;return d|0}function Pd(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0;j=i;i=i+16|0;h=j+8|0;f=j;if(a){g=a+7062388|0;if((c[g>>2]|0)!=(b|0)){d=a+7062408|0;e=c[d>>2]|0;if(e){pe(e);c[d>>2]=0}switch(b|0){case 3:case 2:case 1:{c[d>>2]=oe(c[a+36>>2]|0,c[a+40>>2]|0,c[a+4>>2]|0,0)|0;break}case 4:{c[a+7062404>>2]=1;c[a+7062400>>2]=1;b=4;break}case 0:{b=0;break}default:{Me(3,3985,f);b=0}}c[g>>2]=b;if((c[a>>2]|0)==1){c[h>>2]=c[760+(b<<2)>>2];Me(3,4059,h);b=0}else b=0}else b=0}else b=-1;i=j;return b|0}function Qd(a){a=a|0;var b=0,d=0;if(!a)b=-1;else{b=a+7062408|0;d=c[b>>2]|0;if(d){pe(d);c[b>>2]=0}Vj(c[a+4834144>>2]|0);Vj(c[a+4834148>>2]|0);Vj(a);b=0}return b|0}function Rd(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a>>2];a=0}else a=-1;return a|0}function Sd(a,b){a=a|0;b=b|0;if((a|0)!=0&b>>>0<2){c[a+12>>2]=b;a=0}else a=-1;return a|0}function Td(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a+12>>2];a=0}else a=-1;return a|0}function Ud(a,b){a=a|0;b=b|0;if((a|0)==0|b>>>0>255)a=-1;else{c[a+16>>2]=b;a=0}return a|0}function Vd(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a+16>>2];a=0}else a=-1;return a|0}function Wd(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a+7062388>>2];a=0}else a=-1;return a|0}function Xd(a,b){a=a|0;b=b|0;if((a|0)!=0&b>>>0<2){c[a+20>>2]=b;a=0}else a=-1;return a|0}function Yd(a,b){a=a|0;b=b|0;if(!a)a=-1;else{c[b>>2]=c[a+20>>2];a=0}return a|0}function Zd(a,b){a=a|0;b=b|0;if((a|0)!=0&b>>>0<5){c[a+24>>2]=b;a=0}else a=-1;return a|0}function _d(a,b){a=a|0;b=b|0;if(!a)a=-1;else{c[a+7062424>>2]=b;a=0}return a|0}function $d(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a+7062424>>2];a=0}else a=-1;return a|0}function ae(a,b){a=a|0;b=b|0;if(!a)a=-1;else{c[b>>2]=c[a+24>>2];a=0}return a|0}function be(a,b){a=a|0;b=+b;if((a|0)!=0?!(b<=0.0|b>=1.0):0){h[a+7062416>>3]=b;a=0}else a=-1;return a|0}function ce(a,b){a=a|0;b=b|0;if(!a)a=-1;else{h[b>>3]=+h[a+7062416>>3];a=0}return a|0}function de(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,j=0.0,k=0,l=0,m=0,n=0.0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0.0,P=0,Q=0,R=0.0,S=0.0;Q=i;i=i+80|0;M=Q+32|0;G=Q+24|0;z=Q;y=Q+52|0;D=Q+40|0;L=Q+64|0;P=a+44|0;c[P>>2]=0;J=a+7062388|0;f=c[J>>2]|0;a:do if((f|0)==4){I=a+7062396|0;e=c[I>>2]|0;do if((e|0)>0){f=4;e=e+-1|0}else{C=a+16|0;F=c[C>>2]|0;E=a+7062400|0;A=(c[E>>2]|0)+F|0;A=(A|0)>255?255:A;c[y>>2]=A;H=a+7062404|0;B=F-(c[H>>2]|0)|0;B=(B|0)<0?0:B;c[y+4>>2]=B;c[y+8>>2]=F;e=a+36|0;f=a+40|0;g=a+4|0;k=a+12|0;l=a+20|0;m=a+4834144|0;p=a+15416|0;q=a+15408|0;r=a+7062384|0;s=a+24|0;t=a+32|0;u=a+7062416|0;v=a+48|0;w=a+7062424|0;x=0;do{if((xe(b,c[e>>2]|0,c[f>>2]|0,c[g>>2]|0,c[a>>2]|0,c[k>>2]|0,c[y+(x<<2)>>2]|0,c[l>>2]|0,m,0)|0)<0){e=-1;break a}if((fe(c[e>>2]|0,c[f>>2]|0,m,c[l>>2]|0,1e6,70,1.0,p,q)|0)<0){e=-1;break a}if((je(b,c[e>>2]|0,c[f>>2]|0,c[g>>2]|0,p,c[q>>2]|0,c[r>>2]|0,c[l>>2]|0,c[s>>2]|0,(c[t>>2]|0)+184|0,+h[u>>3],v,P,c[w>>2]|0)|0)<0){e=-1;break a}c[D+(x<<2)>>2]=c[P>>2];x=x+1|0}while((x|0)<3);if((c[a>>2]|0)==1){N=c[D+4>>2]|0;g=c[D+8>>2]|0;f=c[D>>2]|0;c[z>>2]=B;c[z+4>>2]=N;c[z+8>>2]=F;c[z+12>>2]=g;c[z+16>>2]=A;c[z+20>>2]=f;Me(3,4153,z)}else{f=c[D>>2]|0;g=c[D+8>>2]|0}e=c[D+4>>2]|0;if((f|0)>(g|0)|(e|0)>(g|0)){f=(f|0)>=(e|0)?A:B;c[C>>2]=f;e=f-F|0;if((e|0)>0){c[E>>2]=e;e=1}else{c[E>>2]=1;e=0-e|0}c[H>>2]=e;if((c[a>>2]|0)==1){c[G>>2]=f;Me(3,4229,G)}f=c[J>>2]|0;e=c[a+7062392>>2]|0;break}e=c[E>>2]|0;f=c[H>>2]|0;do if((e|0)>=(f|0))if((e|0)>(f|0)){c[H>>2]=f+1;break}else{e=e+1|0;c[E>>2]=e;c[H>>2]=f+1;break}else{e=e+1|0;c[E>>2]=e}while(0);if((e+F|0)>254){c[E>>2]=1;e=1}if((F|0)<=(e|0))c[H>>2]=1;c[I>>2]=c[a+7062392>>2];N=47;break a}while(0);c[I>>2]=e;N=30}else N=30;while(0);b:do if((N|0)==30){c:do switch(f|0){case 3:{f=a+7062408|0;e=we(c[f>>2]|0,b,9,-7)|0;if((e|0)<0)break b;e=c[f>>2]|0;f=a+4834144|0;e=xe(c[e>>2]|0,c[e+8>>2]|0,c[e+12>>2]|0,5,c[a>>2]|0,c[a+12>>2]|0,0,0,f,c[e+4>>2]|0)|0;if((e|0)<0)break b;e=a+36|0;g=a+40|0;k=a+20|0;break}case 2:case 1:{g=a+7062396|0;e=c[g>>2]|0;if((e|0)>0){c[g>>2]=e+-1;N=44;break c}e=c[a+7062408>>2]|0;if((f|0)==1)e=ue(e,b,L)|0;else e=ve(e,b,L)|0;if((e|0)<0)break b;e=a+16|0;if((c[a>>2]|0)==1?(K=d[L>>0]|0,(c[e>>2]|0)!=(K|0)):0){c[M>>2]=(c[J>>2]|0)==1?4281:4288;c[M+4>>2]=K;Me(3,4293,M)}c[e>>2]=d[L>>0];c[g>>2]=c[a+7062392>>2];N=44;break}default:N=44}while(0);if((N|0)==44){e=a+36|0;g=a+40|0;k=a+20|0;f=a+4834144|0;if((xe(b,c[e>>2]|0,c[g>>2]|0,c[a+4>>2]|0,c[a>>2]|0,c[a+12>>2]|0,c[a+16>>2]|0,c[k>>2]|0,f,0)|0)<0){e=-1;break}}l=a+15416|0;m=a+15408|0;if((fe(c[e>>2]|0,c[g>>2]|0,f,c[k>>2]|0,1e6,70,1.0,l,m)|0)>=0?(je(b,c[e>>2]|0,c[g>>2]|0,c[a+4>>2]|0,l,c[m>>2]|0,c[a+7062384>>2]|0,c[k>>2]|0,c[a+24>>2]|0,(c[a+32>>2]|0)+184|0,+h[a+7062416>>3],a+48|0,P,c[a+7062424>>2]|0)|0)>=0:0)N=47;else e=-1}while(0);d:do if((N|0)==47){t=a+28|0;if((c[t>>2]|0)==1){ee(a);e=0;break}u=a+4818296|0;r=a+24|0;q=c[u>>2]|0;if((q|0)>0){s=0;do{f=c[P>>2]|0;g=a+4818304+(s*264|0)+56|0;k=a+4818304+(s*264|0)+64|0;if((f|0)>0){o=+(c[a+4818304+(s*264|0)>>2]|0);e=-1;l=0;n=.5;while(1){j=+(c[a+48+(l<<8)>>2]|0);R=o/j;if(!(R<.7|R>1.43)?(R=+h[a+48+(l<<8)+56>>3]-+h[g>>3],O=+h[a+48+(l<<8)+64>>3]-+h[k>>3],O=(R*R+O*O)/j,O=(f|0)){p=e;break}else n=j}}else p=-1;e:do if((p|0)>-1){m=c[r>>2]|0;switch(m|0){case 2:case 1:case 0:break;case 4:case 3:{g=a+48+(p<<8)+40|0;j=+h[a+4818304+(s*264|0)+40>>3];if(!(+h[g>>3]>3]<+h[f>>3]))break e}else{f=a+4818304+(s*264|0)+48|0;e=a+48+(p<<8)+48|0}h[g>>3]=j;c[a+48+(p<<8)+8>>2]=c[a+4818304+(s*264|0)+8>>2];h[e>>3]=+h[f>>3];c[a+48+(p<<8)+12>>2]=c[a+4818304+(s*264|0)+12>>2];e=-1;n=1.0e8;g=0;while(1){j=0.0;f=0;do{b=(f+g|0)%4|0;o=+h[a+4818304+(s*264|0)+168+(f<<4)>>3]-+h[a+48+(p<<8)+168+(b<<4)>>3];R=+h[a+4818304+(s*264|0)+168+(f<<4)+8>>3]-+h[a+48+(p<<8)+168+(b<<4)+8>>3];j=j+(o*o+R*R);f=f+1|0}while((f|0)!=4);f=j>2]=(b+(c[a+4818304+(s*264|0)+20>>2]|0)|0)%4|0;c[a+48+(p<<8)+24>>2]=(b+(c[a+4818304+(s*264|0)+24>>2]|0)|0)%4|0;break e}default:{e=-1;break d}}e=a+48+(p<<8)+32|0;o=+h[a+4818304+(s*264|0)+32>>3];if(+h[e>>3]>3]=o;l=c[a+4818304+(s*264|0)+4>>2]|0;c[a+48+(p<<8)+4>>2]=l;g=a+4818304+(s*264|0)+16|0;e=-1;n=1.0e8;k=0;while(1){j=0.0;f=0;do{b=(f+k|0)%4|0;S=+h[a+4818304+(s*264|0)+168+(f<<4)>>3]-+h[a+48+(p<<8)+168+(b<<4)>>3];R=+h[a+4818304+(s*264|0)+168+(f<<4)+8>>3]-+h[a+48+(p<<8)+168+(b<<4)+8>>3];j=j+(S*S+R*R);f=f+1|0}while((f|0)!=4);if(j>2]|0)|0)%4|0;else j=n;k=k+1|0;if((k|0)==4)break;else n=j}c[a+48+(p<<8)+16>>2]=e;if(m>>>0<2){c[a+48+(p<<8)+8>>2]=l;h[a+48+(p<<8)+40>>3]=o;c[a+48+(p<<8)+20>>2]=e;break}else{c[a+48+(p<<8)+12>>2]=l;h[a+48+(p<<8)+48>>3]=o;c[a+48+(p<<8)+24>>2]=e;break}}}while(0);s=s+1|0}while((s|0)<(q|0))}ee(a);if((c[u>>2]|0)>0){g=0;e=0;do{f=a+4818304+(g*264|0)|0;N=a+4818304+(g*264|0)+256|0;b=(c[N>>2]|0)+1|0;c[N>>2]=b;if((b|0)<4){if((g|0)!=(e|0))ik(a+4818304+(e*264|0)|0,f|0,264)|0;e=e+1|0}g=g+1|0}while((g|0)<(c[u>>2]|0))}else e=0;c[u>>2]=e;e=c[P>>2]|0;f:do if((e|0)>0){m=0;do{k=a+48+(m<<8)|0;g=c[a+48+(m<<8)+4>>2]|0;if((g|0)>=0){l=c[u>>2]|0;g:do if((l|0)>0){f=0;do{if((c[a+4818304+(f*264|0)+4>>2]|0)==(g|0))break g;f=f+1|0}while((f|0)<(l|0))}else f=0;while(0);if((f|0)==(l|0)){if((l|0)==60)break f;c[u>>2]=l+1}ik(a+4818304+(f*264|0)|0,k|0,256)|0;c[a+4818304+(f*264|0)+256>>2]=1}m=m+1|0;e=c[P>>2]|0}while((m|0)<(e|0))}while(0);if((c[t>>2]|0)!=2?(c[u>>2]|0)>0:0){l=0;while(1){g=a+4818304+(l*264|0)+56|0;k=a+4818304+(l*264|0)+64|0;h:do if((e|0)>0){n=+(c[a+4818304+(l*264|0)>>2]|0);f=0;do{j=+(c[a+48+(f<<8)>>2]|0);S=n/j;if(!(S<.7|S>1.43)?(R=+h[a+48+(f<<8)+56>>3]-+h[g>>3],S=+h[a+48+(f<<8)+64>>3]-+h[k>>3],(R*R+S*S)/j<.5):0)break h;f=f+1|0}while((f|0)<(e|0))}else f=0;while(0);if((f|0)==(e|0)){ik(a+48+(e<<8)|0,a+4818304+(l*264|0)|0,256)|0;e=(c[P>>2]|0)+1|0;c[P>>2]=e}l=l+1|0;if((l|0)>=(c[u>>2]|0)){e=0;break}}}else e=0}while(0);i=Q;return e|0}function ee(a){a=a|0;var b=0,d=0,e=0,f=0;switch(c[a+24>>2]|0){case 1:case 0:{d=c[a+44>>2]|0;if((d|0)>0){e=0;do{b=a+48+(e<<8)+4|0;if((c[b>>2]|0)>-1?+h[a+48+(e<<8)+32>>3]<.5:0){c[a+48+(e<<8)+8>>2]=-1;c[b>>2]=-1;c[a+48+(e<<8)+236>>2]=6}e=e+1|0}while((e|0)<(d|0))}break}case 2:{d=c[a+44>>2]|0;if((d|0)>0){e=0;do{b=a+48+(e<<8)+4|0;if((c[b>>2]|0)>-1?+h[a+48+(e<<8)+32>>3]<.5:0){c[a+48+(e<<8)+12>>2]=-1;c[b>>2]=-1;c[a+48+(e<<8)+236>>2]=6}e=e+1|0}while((e|0)<(d|0))}break}default:{e=c[a+44>>2]|0;if((e|0)>0){f=0;do{b=a+48+(f<<8)+8|0;if((c[b>>2]|0)>-1?+h[a+48+(f<<8)+40>>3]<.5:0){c[b>>2]=-1;d=0}else d=1;b=a+48+(f<<8)+12|0;if(((c[b>>2]|0)>-1?+h[a+48+(f<<8)+48>>3]<.5:0)?(c[b>>2]=-1,(d|0)==0):0)c[a+48+(f<<8)+236>>2]=6;f=f+1|0}while((f|0)<(e|0))}}}return}function fe(a,b,d,e,f,g,j,k,l){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;j=+j;k=k|0;l=l|0;var m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0.0;L=i;i=i+96|0;F=L+56|0;H=L+48|0;G=L+8|0;I=L;K=(e|0)==1;if(K){a=(a|0)/2|0;b=(b|0)/2|0;f=(f|0)/4|0;g=(g|0)/4|0}c[l>>2]=0;C=d+8|0;D=a+-2|0;z=b+-2|0;A=d+1179664|0;a:do if((c[C>>2]|0)>0){B=0;while(1){w=d+12+(B<<2)|0;y=c[w>>2]|0;b:do if(((((!((y|0)<(g|0)|(y|0)>(f|0))?(E=d+131084+(B<<4)|0,(c[E>>2]|0)!=1):0)?(c[d+131084+(B<<4)+4>>2]|0)!=(D|0):0)?(c[d+131084+(B<<4)+8>>2]|0)!=1:0)?(c[d+131084+(B<<4)+12>>2]|0)!=(z|0):0)?(ge(c[d>>2]|0,a,0,A,B+1|0,E,k+((c[l>>2]|0)*80048|0)|0)|0)>=0:0){t=c[w>>2]|0;x=c[l>>2]|0;u=k+(x*80048|0)+28|0;b=c[u>>2]|0;v=k+(x*80048|0)+40028|0;n=c[v>>2]|0;y=k+(x*80048|0)+24|0;o=(c[y>>2]|0)+-1|0;if((o|0)>1){r=0;s=1;e=0;while(1){p=(c[k+(x*80048|0)+28+(s<<2)>>2]|0)-b|0;p=$(p,p)|0;q=(c[k+(x*80048|0)+40028+(s<<2)>>2]|0)-n|0;p=($(q,q)|0)+p|0;q=(p|0)>(r|0);e=q?s:e;s=s+1|0;if((s|0)>=(o|0))break;else r=q?p:r}}else e=0;m=+(t|0)/.75*.01*j;c[H>>2]=0;c[I>>2]=0;c:do if((he(u,v,0,e,m,F,H)|0)>=0?(he(u,v,e,(c[y>>2]|0)+-1|0,m,G,I)|0)>=0:0){b=c[H>>2]|0;n=c[I>>2]|0;do if((b|0)==1&(n|0)==1){b=c[G>>2]|0;n=c[F>>2]|0}else{if((b|0)>1&(n|0)==0){b=(e|0)/2|0;c[I>>2]=0;c[H>>2]=0;if((he(u,v,0,b,m,F,H)|0)<0)break c;if((he(u,v,b,e,m,G,I)|0)<0)break c;if(!((c[H>>2]|0)==1&(c[I>>2]|0)==1))break c;b=e;n=c[F>>2]|0;e=c[G>>2]|0;break}if(!((b|0)==0&(n|0)>1))break c;b=(e+-1+(c[y>>2]|0)|0)/2|0;c[I>>2]=0;c[H>>2]=0;if((he(u,v,e,b,m,F,H)|0)<0)break c;if((he(u,v,b,(c[y>>2]|0)+-1|0,m,G,I)|0)<0)break c;if(!((c[H>>2]|0)==1&(c[I>>2]|0)==1))break c;b=c[G>>2]|0;n=e;e=c[F>>2]|0}while(0);c[k+(x*80048|0)+80028>>2]=0;c[k+(x*80048|0)+80032>>2]=n;c[k+(x*80048|0)+80036>>2]=e;c[k+(x*80048|0)+80040>>2]=b;c[k+(x*80048|0)+80044>>2]=(c[y>>2]|0)+-1;c[k+((c[l>>2]|0)*80048|0)>>2]=c[w>>2];y=c[l>>2]|0;h[k+(y*80048|0)+8>>3]=+h[d+655376+(B<<4)>>3];h[k+(y*80048|0)+16>>3]=+h[d+655376+(B<<4)+8>>3];y=y+1|0;c[l>>2]=y;if((y|0)==60){e=60;break a}else break b}while(0)}while(0);B=B+1|0;if((B|0)>=(c[C>>2]|0)){J=4;break}}}else J=4;while(0);if((J|0)==4)e=c[l>>2]|0;if((e|0)>0){o=0;do{a=o;o=o+1|0;g=k+(a*80048|0)+16|0;n=k+(a*80048|0)|0;if((o|0)<(e|0)){j=+h[k+(a*80048|0)+8>>3];f=o;do{M=j-+h[k+(f*80048|0)+8>>3];m=+h[g>>3]-+h[k+(f*80048|0)+16>>3];m=M*M+m*m;e=c[n>>2]|0;a=k+(f*80048|0)|0;b=c[a>>2]|0;if((e|0)>(b|0)){if(m<+((e|0)/4|0|0))c[a>>2]=0}else if(m<+((b|0)/4|0|0))c[n>>2]=0;f=f+1|0;e=c[l>>2]|0}while((f|0)<(e|0))}}while((o|0)<(e|0))}if((e|0)>0){f=0;do{if(!(c[k+(f*80048|0)>>2]|0)){a=f+1|0;if((a|0)<(e|0)){e=f;b=a;while(1){ik(k+(e*80048|0)|0,k+(b*80048|0)|0,80048)|0;e=c[l>>2]|0;a=b+1|0;if((a|0)<(e|0)){e=b;b=a}else break}}e=e+-1|0;c[l>>2]=e}f=f+1|0}while((f|0)<(e|0))}if(K&(e|0)>0){b=0;while(1){c[k>>2]=c[k>>2]<<2;e=k+8|0;h[e>>3]=+h[e>>3]*2.0;e=k+16|0;h[e>>3]=+h[e>>3]*2.0;e=k+24|0;if((c[e>>2]|0)>0){a=0;do{K=k+28+(a<<2)|0;c[K>>2]=c[K>>2]<<1;K=k+40028+(a<<2)|0;c[K>>2]=c[K>>2]<<1;a=a+1|0}while((a|0)<(c[e>>2]|0))}b=b+1|0;if((b|0)>=(c[l>>2]|0))break;else k=k+80048|0}}i=L;return 0}function ge(a,d,e,f,g,h,j){a=a|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;w=i;i=i+80032|0;p=w+16|0;o=w+8|0;l=w;u=w+40024|0;v=w+24|0;t=c[h+8>>2]|0;e=c[h>>2]|0;h=c[h+4>>2]|0;a:do if((e|0)<=(h|0)){k=e;e=a+(($(t,d)|0)+e<<1)|0;while(1){s=b[e>>1]|0;if(s<<16>>16>0?(c[f+((s<<16>>16)+-1<<2)>>2]|0)==(g|0):0){n=k;break}if((k|0)<(h|0)){k=k+1|0;e=e+2|0}else{x=6;break a}}q=j+24|0;c[q>>2]=1;r=j+28|0;c[r>>2]=n;s=j+40028|0;c[s>>2]=t;f=t;m=n;k=1;e=5;while(1){h=(e+5|0)%8|0;e=0;while(1){g=c[776+(h<<2)>>2]|0;l=c[808+(h<<2)>>2]|0;if((b[a+(l+m+($(g+f|0,d)|0)<<1)>>1]|0)>0){e=g;g=h;break}e=e+1|0;h=(h+1|0)%8|0;if((e|0)>=8){x=11;break}}if((x|0)==11){x=0;if((e|0)==8){x=13;break}l=c[808+(h<<2)>>2]|0;e=c[776+(h<<2)>>2]|0;g=h}c[j+28+(k<<2)>>2]=l+m;h=c[q>>2]|0;c[j+40028+(h<<2)>>2]=e+(c[j+40028+(h+-1<<2)>>2]|0);e=c[q>>2]|0;h=j+28+(e<<2)|0;if((c[h>>2]|0)==(n|0)?(c[j+40028+(e<<2)>>2]|0)==(t|0):0){f=e;x=16;break}k=e+1|0;c[q>>2]=k;if((k|0)==9999){x=19;break}f=c[j+40028+(e<<2)>>2]|0;m=c[h>>2]|0;e=g}if((x|0)==13){Me(3,4347,o);e=-1;break}else if((x|0)==16){if((f|0)>1){l=0;g=1;h=0;while(1){e=(c[j+28+(g<<2)>>2]|0)-n|0;e=$(e,e)|0;k=(c[j+40028+(g<<2)>>2]|0)-t|0;e=($(k,k)|0)+e|0;k=(e|0)>(l|0);h=k?g:h;g=g+1|0;if((g|0)>=(f|0))break;else l=k?e:l}}else h=0;if((h|0)>0){e=0;do{c[u+(e<<2)>>2]=c[j+28+(e<<2)>>2];c[v+(e<<2)>>2]=c[j+40028+(e<<2)>>2];e=e+1|0}while((e|0)<(h|0))}if((h|0)<(f|0)){e=h;do{t=e-h|0;c[j+28+(t<<2)>>2]=c[j+28+(e<<2)>>2];c[j+40028+(t<<2)>>2]=c[j+40028+(e<<2)>>2];e=e+1|0}while((e|0)<(c[q>>2]|0))}if((h|0)>0){e=0;do{t=e-h|0;c[j+28+((c[q>>2]|0)+t<<2)>>2]=c[u+(e<<2)>>2];c[j+40028+((c[q>>2]|0)+t<<2)>>2]=c[v+(e<<2)>>2];e=e+1|0}while((e|0)<(h|0))}c[j+28+(c[q>>2]<<2)>>2]=c[r>>2];c[j+40028+(c[q>>2]<<2)>>2]=c[s>>2];c[q>>2]=(c[q>>2]|0)+1;e=0;break}else if((x|0)==19){Me(3,4354,p);e=-1;break}}else x=6;while(0);if((x|0)==6){Me(3,4340,l);e=-1}i=w;return e|0}function he(a,b,d,e,f,g,h){a=a|0;b=b|0;d=d|0;e=e|0;f=+f;g=g|0;h=h|0;var i=0,j=0.0,k=0.0,l=0,m=0.0,n=0,o=0.0,p=0,q=0,r=0,s=0.0;i=c[b+(e<<2)>>2]|0;q=c[b+(d<<2)>>2]|0;o=+(i-q|0);l=c[a+(d<<2)>>2]|0;r=c[a+(e<<2)>>2]|0;m=+(l-r|0);k=+(($(r,q)|0)-($(l,i)|0)|0);i=d+1|0;if((i|0)<(e|0)){j=0.0;l=i;do{s=k+(o*+(c[a+(l<<2)>>2]|0)+m*+(c[b+(l<<2)>>2]|0));s=s*s;r=s>j;j=r?s:j;i=r?l:i;l=l+1|0}while((l|0)<(e|0))}else j=0.0;if(j/(o*o+m*m)>f)if(((he(a,b,d,i,f,g,h)|0)>=0?(n=c[h>>2]|0,(n|0)<=5):0)?(c[g+(n<<2)>>2]=i,c[h>>2]=(c[h>>2]|0)+1,(he(a,b,i,e,f,g,h)|0)>=0):0)p=7;else i=-1;else p=7;if((p|0)==7)i=0;return i|0}function ie(a,b,d,e,f,j,k){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;j=j|0;k=k|0;var l=0,m=0.0,n=0,o=0.0,p=0.0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;y=i;i=i+16|0;t=y+4|0;u=y;v=nf(2)|0;w=nf(2)|0;x=Re(2,2)|0;q=0;a:while(1){r=q;q=q+1|0;s=c[e+(q<<2)>>2]|0;l=c[e+(r<<2)>>2]|0;p=+(s+1-l|0)*.05+.5;l=~~(+(l|0)+p);s=~~(+(s|0)-p)-l|0;n=s+1|0;d=Re(n,2)|0;if((s|0)>-1){s=0;do{z=s+l|0;if((mf(f,+(c[a+(z<<2)>>2]|0),+(c[b+(z<<2)>>2]|0),t,u)|0)<0){l=10;break a}z=s<<1;A=c[d>>2]|0;h[A+(z<<3)>>3]=+g[t>>2];h[A+((z|1)<<3)>>3]=+g[u>>2];s=s+1|0}while((s|0)<(n|0))}if((Ye(d,x,v,w)|0)<0){l=10;break}A=c[x>>2]|0;o=+h[A+8>>3];h[j+(r*24|0)>>3]=o;p=-+h[A>>3];h[j+(r*24|0)+8>>3]=p;A=c[w>>2]|0;h[j+(r*24|0)+16>>3]=-(o*+h[A>>3]+ +h[A+8>>3]*p);We(d)|0;if((q|0)>=4){l=7;break}}b:do if((l|0)==7){We(x)|0;of(w)|0;of(v)|0;q=0;while(1){d=(q+3|0)%4|0;l=j+(d*24|0)|0;m=+h[j+(q*24|0)+8>>3];n=j+(q*24|0)|0;o=+h[j+(d*24|0)+8>>3];p=+h[l>>3]*m-+h[n>>3]*o;if(+O(+p)<.0001){d=-1;break b}A=j+(q*24|0)+16|0;z=j+(d*24|0)+16|0;h[k+(q<<4)>>3]=(o*+h[A>>3]-m*+h[z>>3])/p;h[k+(q<<4)+8>>3]=(+h[n>>3]*+h[z>>3]-+h[l>>3]*+h[A>>3])/p;q=q+1|0;if((q|0)>=4){d=0;break}}}else if((l|0)==10){We(d)|0;We(x)|0;of(w)|0;of(v)|0;d=-1}while(0);i=y;return d|0}function je(a,b,d,e,f,j,k,l,m,n,o,p,q,r){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=+o;p=p|0;q=q|0;r=r|0;var s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;D=F+4|0;E=F;z=m>>>0<2;A=(m|0)==2;if((j|0)>0){C=0;s=0;do{c[p+(s<<8)>>2]=c[f+(C*80048|0)>>2];if((mf(n,+h[f+(C*80048|0)+8>>3],+h[f+(C*80048|0)+16>>3],D,E)|0)>=0?(h[p+(s<<8)+56>>3]=+g[D>>2],h[p+(s<<8)+64>>3]=+g[E>>2],B=p+(s<<8)+168|0,(ie(f+(C*80048|0)+28|0,f+(C*80048|0)+40028|0,c[f+(C*80048|0)+24>>2]|0,f+(C*80048|0)+80028|0,n,p+(s<<8)+72|0,B)|0)>=0):0){t=p+(s<<8)+8|0;u=p+(s<<8)+20|0;v=p+(s<<8)+40|0;w=p+(s<<8)+12|0;x=p+(s<<8)+24|0;y=p+(s<<8)+48|0;switch(De(k,l,m,a,b,d,e,n,B,o,t,u,v,w,x,y,r,p+(s<<8)+240|0,p+(s<<8)+248|0)|0){case 0:{c[p+(s<<8)+236>>2]=0;break}case-1:{c[p+(s<<8)+236>>2]=2;break}case-2:{c[p+(s<<8)+236>>2]=3;break}case-3:{c[p+(s<<8)+236>>2]=4;break}case-4:{c[p+(s<<8)+236>>2]=5;break}case-5:{c[p+(s<<8)+236>>2]=9;break}case-6:{c[p+(s<<8)+236>>2]=1;break}default:{}}if(!z){if(A){c[p+(s<<8)+4>>2]=c[w>>2];c[p+(s<<8)+16>>2]=c[x>>2];h[p+(s<<8)+32>>3]=+h[y>>3]}}else{c[p+(s<<8)+4>>2]=c[t>>2];c[p+(s<<8)+16>>2]=c[u>>2];h[p+(s<<8)+32>>3]=+h[v>>3]}s=s+1|0}C=C+1|0}while((C|0)<(j|0))}else s=0;c[q>>2]=s;i=F;return 0}function ke(a,b,d,e){a=a|0;b=b|0;d=+d;e=e|0;var f=0,g=0,j=0,k=0,l=0,m=0,n=0.0,o=0,p=0;k=i;i=i+288|0;m=k+200|0;l=k+104|0;f=k+264|0;j=k+8|0;g=k;o=c[b+16>>2]|0;p=(4-o|0)%4|0;h[m>>3]=+h[b+168+(p<<4)>>3];h[m+8>>3]=+h[b+168+(p<<4)+8>>3];p=(5-o|0)%4|0;h[m+16>>3]=+h[b+168+(p<<4)>>3];h[m+24>>3]=+h[b+168+(p<<4)+8>>3];p=(6-o|0)%4|0;h[m+32>>3]=+h[b+168+(p<<4)>>3];h[m+40>>3]=+h[b+168+(p<<4)+8>>3];o=(7-o|0)%4|0;h[m+48>>3]=+h[b+168+(o<<4)>>3];h[m+56>>3]=+h[b+168+(o<<4)+8>>3];n=d*-.5;h[l>>3]=n;d=d*.5;h[l+8>>3]=d;h[l+16>>3]=0.0;h[l+24>>3]=d;h[l+32>>3]=d;h[l+40>>3]=0.0;h[l+48>>3]=d;h[l+56>>3]=n;h[l+64>>3]=0.0;h[l+72>>3]=n;h[l+80>>3]=n;h[l+88>>3]=0.0;c[f>>2]=m;c[f+4>>2]=l;c[f+8>>2]=4;if((Ef(c[a>>2]|0,m,l,4,j)|0)<0)d=1.0e8;else{p=(zf(c[a>>2]|0,f,j,e,g)|0)<0;d=p?1.0e8:+h[g>>3]}i=k;return+d}function le(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=+e;f=f|0;var g=0,j=0,k=0,l=0,m=0,n=0.0,o=0,p=0;j=i;i=i+192|0;m=j+104|0;l=j+8|0;k=j+168|0;g=j;o=c[b+16>>2]|0;p=(4-o|0)%4|0;h[m>>3]=+h[b+168+(p<<4)>>3];h[m+8>>3]=+h[b+168+(p<<4)+8>>3];p=(5-o|0)%4|0;h[m+16>>3]=+h[b+168+(p<<4)>>3];h[m+24>>3]=+h[b+168+(p<<4)+8>>3];p=(6-o|0)%4|0;h[m+32>>3]=+h[b+168+(p<<4)>>3];h[m+40>>3]=+h[b+168+(p<<4)+8>>3];o=(7-o|0)%4|0;h[m+48>>3]=+h[b+168+(o<<4)>>3];h[m+56>>3]=+h[b+168+(o<<4)+8>>3];n=e*-.5;h[l>>3]=n;e=e*.5;h[l+8>>3]=e;h[l+16>>3]=0.0;h[l+24>>3]=e;h[l+32>>3]=e;h[l+40>>3]=0.0;h[l+48>>3]=e;h[l+56>>3]=n;h[l+64>>3]=0.0;h[l+72>>3]=n;h[l+80>>3]=n;h[l+88>>3]=0.0;c[k>>2]=m;c[k+4>>2]=l;c[k+8>>2]=4;b=(zf(c[a>>2]|0,k,d,f,g)|0)<0;i=j;return+(b?1.0e8:+h[g>>3])}function me(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0;p=i;i=i+32|0;m=p+20|0;n=p;j=Uj(f<<4)|0;c[m>>2]=j;if(!j){Me(3,5472,p+8|0);rb(1)}k=Uj(f*24|0)|0;l=m+4|0;c[l>>2]=k;if(!k){Me(3,5472,p+16|0);rb(1)}if((f|0)>0){o=0;do{h[j+(o<<4)>>3]=+h[d+(o<<4)>>3];h[j+(o<<4)+8>>3]=+h[d+(o<<4)+8>>3];h[k+(o*24|0)>>3]=+h[e+(o*24|0)>>3];h[k+(o*24|0)+8>>3]=+h[e+(o*24|0)+8>>3];h[k+(o*24|0)+16>>3]=+h[e+(o*24|0)+16>>3];o=o+1|0}while((o|0)<(f|0))}c[m+8>>2]=f;if((zf(c[a>>2]|0,m,b,g,n)|0)<0)h[n>>3]=1.0e8;Vj(c[m>>2]|0);Vj(c[l>>2]|0);i=p;return+ +h[n>>3]}function ne(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0;p=i;i=i+32|0;m=p+20|0;n=p;j=Uj(f<<4)|0;c[m>>2]=j;if(!j){Me(3,5472,p+8|0);rb(1)}k=Uj(f*24|0)|0;l=m+4|0;c[l>>2]=k;if(!k){Me(3,5472,p+16|0);rb(1)}if((f|0)>0){o=0;do{h[j+(o<<4)>>3]=+h[d+(o<<4)>>3];h[j+(o<<4)+8>>3]=+h[d+(o<<4)+8>>3];h[k+(o*24|0)>>3]=+h[e+(o*24|0)>>3];h[k+(o*24|0)+8>>3]=+h[e+(o*24|0)+8>>3];h[k+(o*24|0)+16>>3]=+h[e+(o*24|0)+16>>3];o=o+1|0}while((o|0)<(f|0))}c[m+8>>2]=f;if((Bf(c[a>>2]|0,m,b,g,n)|0)<0)h[n>>3]=1.0e8;Vj(c[m>>2]|0);Vj(c[l>>2]|0);i=p;return+ +h[n>>3]}function oe(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;f=Uj(2080)|0;a:do if(f){c[f+2068>>2]=d;b:do if(!e){switch(d|0){case 5:case 12:case 13:case 14:break;default:{g=4;break b}}c[f+2076>>2]=0}else g=4;while(0);do if((g|0)==4){g=Uj($(b,a)|0)|0;c[f>>2]=g;if(!g){Vj(f);f=0;break a}else{c[f+2076>>2]=1;break}}while(0);c[f+2072>>2]=e;c[f+4>>2]=0;c[f+8>>2]=a;c[f+12>>2]=b}while(0);return f|0}function pe(a){a=a|0;if(a){if(c[a+2076>>2]|0)Vj(c[a>>2]|0);Vj(c[a+4>>2]|0);Vj(a)}return}function qe(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0;k=i;i=i+16|0;g=k;f=c[b+2068>>2]|0;a:do switch(f|0){case 5:case 12:case 13:case 14:if(!(c[b+2072>>2]|0)){c[b>>2]=e;f=0;break a}else{ik(c[b>>2]|0,e|0,$(c[b+12>>2]|0,c[b+8>>2]|0)|0)|0;f=0;break a}default:{if((f&-2|0)==2){f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=(((d[e+(j|1)>>0]|0)+(d[e+j>>0]|0)+(d[e+(j|2)>>0]|0)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break a}else j=j+4|0}}if((f&-3|0)==4){f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=(((d[e+(j|2)>>0]|0)+(d[e+(j|1)>>0]|0)+(d[e+(j|3)>>0]|0)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break a}else j=j+4|0}}if(f>>>0<2){f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=(((d[e+(j+1)>>0]|0)+(d[e+j>>0]|0)+(d[e+(j+2)>>0]|0)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break a}else j=j+3|0}}switch(f|0){case 8:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=a[e+j>>0]|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}case 7:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=a[e+(j|1)>>0]|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}case 9:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){m=d[e+j>>0]|0;l=d[e+(j|1)>>0]|0;a[(c[b>>2]|0)+h>>0]=(((m&248)+10+(m<<5&224)+(l>>>3&28)+(l<<3&248)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}case 10:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){l=d[e+j>>0]|0;m=d[e+(j|1)>>0]|0;a[(c[b>>2]|0)+h>>0]=(((l&248)+12+(l<<5&224)+(m>>>3&24)+(m<<2&248)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}case 11:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){m=d[e+j>>0]|0;a[(c[b>>2]|0)+h>>0]=(((m&240)+24+(m<<4&240)+((d[e+(j|1)>>0]|0)&240)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}default:{Me(3,4361,g);f=-1;break a}}}}while(0);i=k;return f|0}function re(a,b){a=a|0;b=b|0;var e=0,f=0;if((a|0)!=0&(b|0)!=0?(qe(a,b)|0)>=0:0){ek(a+16|0,0,1024)|0;b=c[a>>2]|0;f=$(c[a+12>>2]|0,c[a+8>>2]|0)|0;e=b+f|0;if((f|0)>0){do{f=a+16+((d[b>>0]|0)<<2)|0;c[f>>2]=(c[f>>2]|0)+1;b=b+1|0}while(b>>>0>>0);b=0}else b=0}else b=-1;return b|0}function se(a,b){a=a|0;b=b|0;var d=0;b=re(a,b)|0;if((b|0)>=0){b=0;d=0;do{b=(c[a+16+(d<<2)>>2]|0)+b|0;c[a+1040+(d<<2)>>2]=b;d=d+1|0}while((d|0)!=256);b=0}return b|0}function te(b,d,e,f){b=b|0;d=d|0;e=+e;f=f|0;var g=0,h=0,i=0;if(!(e<0.0|e>1.0)){d=se(b,d)|0;if((d|0)>=0){i=~~(+($(c[b+12>>2]|0,c[b+8>>2]|0)|0)*e)>>>0;d=0;while(1){h=d&255;g=c[b+1040+(h<<2)>>2]|0;if(g>>>0>>0)d=d+1<<24>>24;else break}if((g|0)==(i|0))do d=d+1<<24>>24;while((c[b+1040+((d&255)<<2)>>2]|0)==(i|0));a[f>>0]=((d&255)+h|0)>>>1;d=0}}else d=-1;return d|0}function ue(a,b,c){a=a|0;b=b|0;c=c|0;return te(a,b,.5,c)|0}function ve(b,d,e){b=b|0;d=d|0;e=e|0;var f=0.0,g=0,h=0.0,i=0.0,j=0.0,k=0.0,l=0,m=0.0,n=0.0;d=re(b,d)|0;if((d|0)>=0){d=1;f=0.0;do{f=f+ +(($(c[b+16+(d<<2)>>2]|0,d)|0)>>>0);d=d+1|0}while((d|0)!=256);k=+($(c[b+12>>2]|0,c[b+8>>2]|0)|0);l=0;h=0.0;d=0;j=0.0;m=0.0;while(1){g=c[b+16+(l<<2)>>2]|0;m=m+ +(g>>>0);if(m!=0.0){i=k-m;if(i==0.0)break;h=h+ +(($(l,g)|0)>>>0);n=h/m-(f-h)/i;i=n*(m*i*n);if(i>j)d=l&255;else i=j}else i=j;if((l&255)<<24>>24==-1)break;else{l=l+1|0;j=i}}a[e>>0]=d;d=0}return d|0}function we(b,e,f,g){b=b|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;e=re(b,e)|0;do if((e|0)>=0){t=b+4|0;if(!(c[t>>2]|0)){e=b+8|0;h=b+12|0;s=Uj($(c[h>>2]|0,c[e>>2]|0)|0)|0;c[t>>2]=s;if(!s){e=-1;break}else s=e}else{s=b+8|0;h=b+12|0}q=f>>1;r=0-q|0;e=c[h>>2]|0;if((e|0)>0){n=(q|0)<(r|0);o=(q|0)<(r|0);p=0;do{e=c[s>>2]|0;if((e|0)>0){m=0;do{if(n){i=0;f=0}else{i=0;l=r;f=0;while(1){j=l+p|0;if(((j|0)>=0?(j|0)<(c[h>>2]|0):0)?(u=$(e,j)|0,!o):0){k=r;while(1){j=k+m|0;if((j|0)>-1&(j|0)<(e|0)){i=i+1|0;f=(d[(c[b>>2]|0)+(u+j)>>0]|0)+f|0}if((k|0)<(q|0))k=k+1|0;else break}}if((l|0)<(q|0))l=l+1|0;else break}}l=($(e,p)|0)+m|0;a[(c[t>>2]|0)+l>>0]=(f|0)/(i|0)|0;m=m+1|0;e=c[s>>2]|0}while((m|0)<(e|0))}p=p+1|0;e=c[h>>2]|0}while((p|0)<(e|0))}if((g|0)!=0?($(e,c[s>>2]|0)|0)>0:0){e=0;do{b=(c[t>>2]|0)+e|0;a[b>>0]=(d[b>>0]|0)+g;e=e+1|0}while((e|0)<($(c[h>>2]|0,c[s>>2]|0)|0));e=0}else e=0}while(0);return e|0}function xe(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0;a:do switch(e|0){case 0:{switch(f|0){case 1:{if(j){k=Fc(a,b,c,j,i)|0;break a}switch(h|0){case 0:{if(d>>>0<2){k=wc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=yc(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=Bc(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=Cc(a,b,c,g,i)|0;break a}case 8:{k=Ec(a,b,c,g,i)|0;break a}case 7:{k=Dc(a,b,c,g,i)|0;break a}case 9:{k=xc(a,b,c,g,i)|0;break a}case 10:{k=Ac(a,b,c,g,i)|0;break a}case 11:{k=zc(a,b,c,g,i)|0;break a}default:rb(0)}break}case 1:{if(d>>>0<2){k=nc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=pc(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=sc(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=tc(a,b,c,g,i)|0;break a}case 8:{k=vc(a,b,c,g,i)|0;break a}case 7:{k=uc(a,b,c,g,i)|0;break a}case 9:{k=oc(a,b,c,g,i)|0;break a}case 10:{k=rc(a,b,c,g,i)|0;break a}case 11:{k=qc(a,b,c,g,i)|0;break a}default:rb(0)}break}default:rb(0)}break}case 0:{if(j){k=Yc(a,b,c,j,i)|0;break a}switch(h|0){case 0:{if(d>>>0<2){k=Pc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=Rc(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=Uc(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=Vc(a,b,c,g,i)|0;break a}case 8:{k=Xc(a,b,c,g,i)|0;break a}case 7:{k=Wc(a,b,c,g,i)|0;break a}case 9:{k=Qc(a,b,c,g,i)|0;break a}case 10:{k=Tc(a,b,c,g,i)|0;break a}case 11:{k=Sc(a,b,c,g,i)|0;break a}default:rb(0)}break}case 1:{if(d>>>0<2){k=Gc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=Ic(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=Lc(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=Mc(a,b,c,g,i)|0;break a}case 8:{k=Oc(a,b,c,g,i)|0;break a}case 7:{k=Nc(a,b,c,g,i)|0;break a}case 9:{k=Hc(a,b,c,g,i)|0;break a}case 10:{k=Kc(a,b,c,g,i)|0;break a}case 11:{k=Jc(a,b,c,g,i)|0;break a}default:rb(0)}break}default:rb(0)}break}default:rb(0)}break}case 1:{switch(f|0){case 1:{if(j){k=pd(a,b,c,j,i)|0;break a}switch(h|0){case 0:{if(d>>>0<2){k=gd(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=id(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=ld(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=md(a,b,c,g,i)|0;break a}case 8:{k=od(a,b,c,g,i)|0;break a}case 7:{k=nd(a,b,c,g,i)|0;break a}case 9:{k=hd(a,b,c,g,i)|0;break a}case 10:{k=kd(a,b,c,g,i)|0;break a}case 11:{k=jd(a,b,c,g,i)|0;break a}default:rb(0)}break}case 1:{if(d>>>0<2){k=Zc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=$c(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=cd(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=dd(a,b,c,g,i)|0;break a}case 8:{k=fd(a,b,c,g,i)|0;break a}case 7:{k=ed(a,b,c,g,i)|0;break a}case 9:{k=_c(a,b,c,g,i)|0;break a}case 10:{k=bd(a,b,c,g,i)|0;break a}case 11:{k=ad(a,b,c,g,i)|0;break a}default:rb(0)}break}default:rb(0)}break}case 0:{if(j){k=Id(a,b,c,j,i)|0;break a}switch(h|0){case 0:{if(d>>>0<2){k=zd(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=Bd(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=Ed(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=Fd(a,b,c,g,i)|0;break a}case 8:{k=Hd(a,b,c,g,i)|0;break a}case 7:{k=Gd(a,b,c,g,i)|0;break a}case 9:{k=Ad(a,b,c,g,i)|0;break a}case 10:{k=Dd(a,b,c,g,i)|0;break a}case 11:{k=Cd(a,b,c,g,i)|0;break a}default:rb(0)}break}case 1:{if(d>>>0<2){k=qd(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=sd(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=vd(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=wd(a,b,c,g,i)|0;break a}case 8:{k=yd(a,b,c,g,i)|0;break a}case 7:{k=xd(a,b,c,g,i)|0;break a}case 9:{k=rd(a,b,c,g,i)|0;break a}case 10:{k=ud(a,b,c,g,i)|0;break a}case 11:{k=td(a,b,c,g,i)|0;break a}default:rb(0)}break}default:rb(0)}break}default:rb(0)}break}default:rb(0)}while(0);return k|0}function ye(a,b){a=a|0;b=b|0;var d=0;if((a|0)!=0?(d=a+7062384|0,(c[d>>2]|0)==0):0){c[d>>2]=b;d=0}else d=-1;return d|0}function ze(a){a=a|0;var b=0;if((a|0)!=0?(b=a+7062384|0,(c[b>>2]|0)!=0):0){c[b>>2]=0;b=0}else b=-1;return b|0}function Ae(){return Be(16,50)|0}function Be(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;r=i;i=i+64|0;q=r+56|0;p=r+48|0;j=r+40|0;h=r+32|0;g=r+24|0;f=r+16|0;e=r+8|0;d=r;a:do if(!((a+-16|0)>>>0>48|(b|0)<1)){n=Uj(32)|0;if(!n){Me(3,5472,d);rb(1)}c[n>>2]=0;c[n+4>>2]=b;c[n+28>>2]=a;m=Uj(b<<2)|0;c[n+8>>2]=m;if(!m){Me(3,5472,e);rb(1)}d=b<<4;l=Uj(d)|0;c[n+12>>2]=l;if(!l){Me(3,5472,f);rb(1)}f=Uj(d)|0;k=n+20|0;c[k>>2]=f;if(!f){Me(3,5472,g);rb(1)}d=b<<5;g=Uj(d)|0;c[n+16>>2]=g;if(!g){Me(3,5472,h);rb(1)}h=Uj(d)|0;c[n+24>>2]=h;if(!h){Me(3,5472,j);rb(1)}e=$(a,a)|0;d=e*12|0;e=e<<2;if((b|0)>0){a=0;b:while(1){c[m+(a<<2)>>2]=0;f=a<<2;h=0;while(1){if((h|0)>=4)break;j=Uj(d)|0;g=h+f|0;c[l+(g<<2)>>2]=j;if(!j){d=18;break b}j=Uj(e)|0;c[(c[k>>2]|0)+(g<<2)>>2]=j;if(!j){d=20;break b}else h=h+1|0}a=a+1|0;if((a|0)>=(b|0)){o=n;break a}}if((d|0)==18){Me(3,5472,p);rb(1)}else if((d|0)==20){Me(3,5472,q);rb(1)}}else o=n}else o=0;while(0);i=r;return o|0}function Ce(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0;if(!a)b=-1;else{b=a+4|0;d=a+8|0;e=a+12|0;f=a+20|0;if((c[b>>2]|0)>0){g=0;do{if(c[(c[d>>2]|0)+(g<<2)>>2]|0)Le(a,g)|0;h=g<<2;Vj(c[(c[e>>2]|0)+(h<<2)>>2]|0);Vj(c[(c[f>>2]|0)+(h<<2)>>2]|0);i=1+h|0;Vj(c[(c[e>>2]|0)+(i<<2)>>2]|0);Vj(c[(c[f>>2]|0)+(i<<2)>>2]|0);i=2+h|0;Vj(c[(c[e>>2]|0)+(i<<2)>>2]|0);Vj(c[(c[f>>2]|0)+(i<<2)>>2]|0);h=3+h|0;Vj(c[(c[e>>2]|0)+(h<<2)>>2]|0);Vj(c[(c[f>>2]|0)+(h<<2)>>2]|0);g=g+1|0}while((g|0)<(c[b>>2]|0))}Vj(a);b=0}return b|0}function De(b,e,f,g,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x){b=b|0;e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=+o;p=p|0;q=q|0;r=r|0;s=s|0;t=t|0;u=u|0;v=v|0;w=w|0;x=x|0;var y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0;L=i;i=i+12448|0;A=L+12440|0;z=L+8|0;J=L;I=L+12312|0;K=L+24|0;do if((f+-2|0)>>>0<3){if((v|0)!=2830){y=v&255;if((Ee(e,2,y,y*3|0,g,j,k,l,m,n,o,K)|0)<0){c[s>>2]=-1;y=-6;break}y=Fe(K,y,s,t,u,v,w)|0;if(!x)break;c[x>>2]=0;c[x+4>>2]=0;break}if((Ee(e,2,14,42,g,j,k,l,m,n,.875,K)|0)<0){c[s>>2]=-1;y=-6;break}c[z>>2]=0;c[z+4>>2]=182;c[z+8>>2]=195;c[z+12>>2]=13;v=a[K+(c[z>>2]|0)>>0]|0;y=(v&255)>0?v:0;v=(v&255)<255?v:-1;H=a[K+(c[z+4>>2]|0)>>0]|0;y=(H&255)>(y&255)?H:y;v=(H&255)<(v&255)?H:v;H=a[K+(c[z+8>>2]|0)>>0]|0;y=(H&255)>(y&255)?H:y;v=(H&255)<(v&255)?H:v;H=a[K+(c[z+12>>2]|0)>>0]|0;y=((H&255)>(y&255)?H:y)&255;v=((H&255)<(v&255)?H:v)&255;a:do if((y-v|0)>=30){H=(y+v|0)>>>1;a[A>>0]=(d[K+(c[z>>2]|0)>>0]|0)>>>0>>0&1;a[A+1>>0]=(d[K+(c[z+4>>2]|0)>>0]|0)>>>0>>0&1;a[A+2>>0]=(d[K+(c[z+8>>2]|0)>>0]|0)>>>0>>0&1;a[A+3>>0]=(d[K+(c[z+12>>2]|0)>>0]|0)>>>0>>0&1;v=0;while(1){y=v+1|0;if(((a[A+v>>0]|0)==1?(a[A+((y|0)%4|0)>>0]|0)==1:0)?(a[A+((v+2|0)%4|0)>>0]|0)==0:0){G=v;break}if((y|0)<4)v=y;else{G=y;break}}switch(G|0){case 4:{c[t>>2]=0;h[u>>3]=-1.0;y=-3;v=0;z=0;break a}case 0:{z=119;y=255;v=0;do{D=v+-3|0;B=(v&-2|0)==12;C=v*14|0;A=0;do{if(((A+-3|D)>>>0>=8?(F=A&-2,(A|v)>>>0>=2):0)?!(B&((F|0)==0|(F|0)==12)):0){E=(d[K+(A+C)>>0]|0)-H|0;a[I+z>>0]=E>>>31;E=(E|0)>-1?E:0-E|0;z=z+-1|0;y=(E|0)<(y|0)?E:y}A=A+1|0}while((A|0)!=14);v=v+1|0}while((v|0)!=14);break}case 1:{z=119;y=255;v=0;do{D=v+-3|0;C=v&-2;B=(C|0)==0;C=(C|0)==12;A=13;while(1){if(((A+-3|D)>>>0>=8?(E=(A&-2|0)==12,!(B&E)):0)?!(C&(A>>>0<2|E)):0){F=(d[K+((A*14|0)+v)>>0]|0)-H|0;a[I+z>>0]=F>>>31;F=(F|0)>-1?F:0-F|0;z=z+-1|0;y=(F|0)<(y|0)?F:y}if((A|0)>0)A=A+-1|0;else break}v=v+1|0}while((v|0)!=14);break}case 2:{v=119;y=255;D=13;while(1){B=D+-3|0;C=D>>>0<2|(D&-2|0)==12;A=D*14|0;z=13;while(1){if((z+-3|B)>>>0>=8?!((z|D)>>>0<2|C&(z&-2|0)==12):0){F=(d[K+(z+A)>>0]|0)-H|0; a[I+v>>0]=F>>>31;F=(F|0)>-1?F:0-F|0;v=v+-1|0;y=(F|0)<(y|0)?F:y}if((z|0)>0)z=z+-1|0;else break}if((D|0)>0)D=D+-1|0;else break}break}case 3:{v=119;y=255;D=13;while(1){C=D+-3|0;B=D&-2;A=(B|0)==12;B=(B|0)==0;z=0;do{if(((z+-3|C)>>>0>=8?!(A&z>>>0<2|(z|D)>>>0<2):0)?!(B&(z&-2|0)==12):0){F=(d[K+((z*14|0)+D)>>0]|0)-H|0;a[I+v>>0]=F>>>31;F=(F|0)>-1?F:0-F|0;v=v+-1|0;y=(F|0)<(y|0)?F:y}z=z+1|0}while((z|0)!=14);if((D|0)>0)D=D+-1|0;else break}break}default:y=255}c[t>>2]=G;h[u>>3]=(y|0)>30?1.0:+(y|0)/30.0;y=Ie(2830,0,0,I,J)|0;if((y|0)<0){y=-4;v=0;z=0}else{if(w)c[w>>2]=y;z=J;y=0;v=c[z>>2]|0;z=c[z+4>>2]|0}}else{c[t>>2]=0;h[u>>3]=-1.0;y=-2;v=0;z=0}while(0);if((y|0)<0){c[s>>2]=-1;break}if((v|0)==-1&(z|0)==-1){c[s>>2]=-1;y=-5;break}c[s>>2]=(v&-32768|0)==0&0==0?v&32767:0;if(!x)y=0;else{y=x;c[y>>2]=v;c[y+4>>2]=z;y=0}}else y=1;while(0);b:do switch(f|0){case 0:case 1:case 3:case 4:{if(!b){c[p>>2]=-1;v=-1;break b}v=b+28|0;z=c[v>>2]|0;A=z<<2;switch(f|0){case 0:case 3:if((Ee(e,0,z,A,g,j,k,l,m,n,o,K)|0)<0){c[p>>2]=-1;v=-6;break b}else{v=Ge(b,0,K,c[v>>2]|0,p,q,r)|0;break b}default:if((Ee(e,1,z,A,g,j,k,l,m,n,o,K)|0)<0){c[p>>2]=-1;v=-6;break b}else{v=Ge(b,1,K,c[v>>2]|0,p,q,r)|0;break b}}}default:v=1}while(0);if((y|0)!=1){if((v|0)!=1)y=(v&y|0)<0?v:0}else y=v;i=L;return y|0}function _j(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0;k=i;i=i+16|0;b=k+8|0;h=k+4|0;d=k;c[h>>2]=a;do if(a>>>0>=212){g=(a>>>0)/210|0;e=g*210|0;c[d>>2]=a-e;b=($j(3712,3904,d,b)|0)-3712>>2;f=b;b=(c[3712+(b<<2)>>2]|0)+e|0;a:while(1){e=5;while(1){if(e>>>0>=47){e=211;j=8;break}d=c[3520+(e<<2)>>2]|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=106;break a}if((b|0)==($(a,d)|0))break;else e=e+1|0}b:do if((j|0)==8)while(1){j=0;d=(b>>>0)/(e>>>0)|0;if(d>>>0>>0){j=105;break a}if((b|0)==($(d,e)|0))break b;d=e+10|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+12|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+16|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+18|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+22|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+28|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+30|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+36|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+40|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+42|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+46|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+52|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+58|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+60|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+66|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+70|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+72|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+78|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+82|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+88|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+96|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+100|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+102|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+106|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+108|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+112|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+120|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+126|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+130|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+136|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+138|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+142|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+148|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+150|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+156|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+162|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+166|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+168|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+172|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+178|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+180|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+186|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+190|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+192|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+196|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+198|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+208|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break;else{e=e+210|0;j=8}}while(0);e=f+1|0;b=(e|0)==48;e=b?0:e;b=(b&1)+g|0;f=e;g=b;b=(c[3712+(e<<2)>>2]|0)+(b*210|0)|0}if((j|0)==105){c[h>>2]=b;break}else if((j|0)==106){c[h>>2]=b;break}}else b=c[($j(3520,3712,h,b)|0)>>2]|0;while(0);i=k;return b|0}function $j(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=c[d>>2]|0;e=a;d=b-a>>2;a:while(1){while(1){if(!d)break a;a=(d|0)/2|0;if((c[e+(a<<2)>>2]|0)>>>0>>0)break;else d=a}e=e+(a+1<<2)|0;d=d+-1-a|0}return e|0}function ak(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0;if(e>>>0>4294967279)oi(b);if(e>>>0<11){a[b>>0]=e<<1;b=b+1|0}else{g=e+16&-16;f=Kh(g)|0;c[b+8>>2]=f;c[b>>2]=g|1;c[b+4>>2]=e;b=f}ik(b|0,d|0,e|0)|0;a[b+e>>0]=0;return}function bk(b){b=b|0;if(a[b>>0]&1)Lh(c[b+8>>2]|0);return}function ck(){}function dk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;d=b-d-(c>>>0>a>>>0|0)>>>0;return(D=d,a-c>>>0|0)|0}function ek(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;f=b+e|0;if((e|0)>=20){d=d&255;h=b&3;i=d|d<<8|d<<16|d<<24;g=f&~3;if(h){h=b+4-h|0;while((b|0)<(h|0)){a[b>>0]=d;b=b+1|0}}while((b|0)<(g|0)){c[b>>2]=i;b=b+4|0}}while((b|0)<(f|0)){a[b>>0]=d;b=b+1|0}return b-e|0}function fk(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){D=b<>>32-c;return a<>>0;return(D=b+d+(c>>>0>>0|0)>>>0,c|0)|0}function hk(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){D=b>>>c;return a>>>c|(b&(1<>>c-32|0}function ik(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;if((e|0)>=4096)return Xa(b|0,d|0,e|0)|0;f=b|0;if((b&3)==(d&3)){while(b&3){if(!e)return f|0;a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}while((e|0)>=4){c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0;e=e-4|0}}while((e|0)>0){a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}return f|0}function jk(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){D=b>>c;return a>>>c|(b&(1<>c-32|0}function kk(b){b=b|0;var c=0;c=a[m+(b&255)>>0]|0;if((c|0)<8)return c|0;c=a[m+(b>>8&255)>>0]|0;if((c|0)<8)return c+8|0;c=a[m+(b>>16&255)>>0]|0;if((c|0)<8)return c+16|0;return(a[m+(b>>>24)>>0]|0)+24|0}function lk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;f=a&65535;e=b&65535;c=$(e,f)|0;d=a>>>16;a=(c>>>16)+($(e,d)|0)|0;e=b>>>16;b=$(e,f)|0;return(D=(a>>>16)+($(e,d)|0)+(((a&65535)+b|0)>>>16)|0,a+b<<16|c&65535|0)|0}function mk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;j=b>>31|((b|0)<0?-1:0)<<1;i=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;f=d>>31|((d|0)<0?-1:0)<<1;e=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;h=dk(j^a,i^b,j,i)|0;g=D;a=f^j;b=e^i;return dk((rk(h,g,dk(f^c,e^d,f,e)|0,D,0)|0)^a,D^b,a,b)|0}function nk(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0;f=i;i=i+16|0;j=f|0;h=b>>31|((b|0)<0?-1:0)<<1;g=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;l=e>>31|((e|0)<0?-1:0)<<1;k=((e|0)<0?-1:0)>>31|((e|0)<0?-1:0)<<1;a=dk(h^a,g^b,h,g)|0;b=D;rk(a,b,dk(l^d,k^e,l,k)|0,D,j)|0;e=dk(c[j>>2]^h,c[j+4>>2]^g,h,g)|0;d=D;i=f;return(D=d,e)|0}function ok(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=a;f=c;c=lk(e,f)|0;a=D;return(D=($(b,f)|0)+($(d,e)|0)+a|a&0,c|0|0)|0}function pk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return rk(a,b,c,d,0)|0}function qk(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;g=i;i=i+16|0;f=g|0;rk(a,b,d,e,f)|0;i=g;return(D=c[f+4>>2]|0,c[f>>2]|0)|0}function rk(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;l=a;j=b;k=j;h=d;n=e;i=n;if(!k){g=(f|0)!=0;if(!i){if(g){c[f>>2]=(l>>>0)%(h>>>0);c[f+4>>2]=0}n=0;f=(l>>>0)/(h>>>0)>>>0;return(D=n,f)|0}else{if(!g){n=0;f=0;return(D=n,f)|0}c[f>>2]=a|0;c[f+4>>2]=b&0;n=0;f=0;return(D=n,f)|0}}g=(i|0)==0;do if(h){if(!g){g=(ba(i|0)|0)-(ba(k|0)|0)|0;if(g>>>0<=31){m=g+1|0;i=31-g|0;b=g-31>>31;h=m;a=l>>>(m>>>0)&b|k<>>(m>>>0)&b;g=0;i=l<>2]=a|0;c[f+4>>2]=j|b&0;n=0;f=0;return(D=n,f)|0}g=h-1|0;if(g&h){i=(ba(h|0)|0)+33-(ba(k|0)|0)|0;p=64-i|0;m=32-i|0;j=m>>31;o=i-32|0;b=o>>31;h=i;a=m-1>>31&k>>>(o>>>0)|(k<>>(i>>>0))&b;b=b&k>>>(i>>>0);g=l<>>(o>>>0))&j|l<>31;break}if(f){c[f>>2]=g&l;c[f+4>>2]=0}if((h|0)==1){o=j|b&0;p=a|0|0;return(D=o,p)|0}else{p=kk(h|0)|0;o=k>>>(p>>>0)|0;p=k<<32-p|l>>>(p>>>0)|0;return(D=o,p)|0}}else{if(g){if(f){c[f>>2]=(k>>>0)%(h>>>0);c[f+4>>2]=0}o=0;p=(k>>>0)/(h>>>0)>>>0;return(D=o,p)|0}if(!l){if(f){c[f>>2]=0;c[f+4>>2]=(k>>>0)%(i>>>0)}o=0;p=(k>>>0)/(i>>>0)>>>0;return(D=o,p)|0}g=i-1|0;if(!(g&i)){if(f){c[f>>2]=a|0;c[f+4>>2]=g&k|b&0}o=0;p=k>>>((kk(i|0)|0)>>>0);return(D=o,p)|0}g=(ba(i|0)|0)-(ba(k|0)|0)|0;if(g>>>0<=30){b=g+1|0;i=31-g|0;h=b;a=k<>>(b>>>0);b=k>>>(b>>>0);g=0;i=l<>2]=a|0;c[f+4>>2]=j|b&0;o=0;p=0;return(D=o,p)|0}while(0);if(!h){k=i;j=0;i=0}else{m=d|0|0;l=n|e&0;k=gk(m|0,l|0,-1,-1)|0;d=D;j=i;i=0;do{e=j;j=g>>>31|j<<1;g=i|g<<1;e=a<<1|e>>>31|0;n=a>>>31|b<<1|0;dk(k,d,e,n)|0;p=D;o=p>>31|((p|0)<0?-1:0)<<1;i=o&1;a=dk(e,n,o&m,(((p|0)<0?-1:0)>>31|((p|0)<0?-1:0)<<1)&l)|0;b=D;h=h-1|0}while((h|0)!=0);k=j;j=0}h=0;if(f){c[f>>2]=a;c[f+4>>2]=b}o=(g|0)>>>31|(k|h)<<1|(h<<1|g>>>31)&0|j;p=(g<<1|0>>>31)&-2|i;return(D=o,p)|0}function sk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Qb[a&15](b|0,c|0,d|0)|0}function tk(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;Rb[a&3](b|0,c|0,d|0,e|0,f|0)}function uk(a,b,c){a=a|0;b=b|0;c=c|0;return+Sb[a&1](b|0,c|0)}function vk(a,b,c){a=a|0;b=b|0;c=+c;Tb[a&3](b|0,+c)}function wk(a,b){a=a|0;b=b|0;return+Ub[a&3](b|0)}function xk(a){a=a|0;return Vb[a&1]()|0}function yk(a,b){a=a|0;b=b|0;Wb[a&15](b|0)}function zk(a,b,c){a=a|0;b=b|0;c=c|0;Xb[a&7](b|0,c|0)}function Ak(a,b){a=a|0;b=b|0;return Yb[a&31](b|0)|0}function Bk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Zb[a&1](b|0,c|0,d|0)}function Ck(a){a=a|0;_b[a&0]()}function Dk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;$b[a&3](b|0,c|0,+d)}function Ek(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ac[a&1](b|0,c|0,d|0,e|0)|0}function Fk(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;bc[a&3](b|0,c|0,d|0,e|0,f|0,g|0)}function Gk(a,b,c){a=a|0;b=b|0;c=c|0;return cc[a&15](b|0,c|0)|0}function Hk(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;dc[a&3](b|0,c|0,d|0,e|0)}function Ik(a,b,c){a=a|0;b=b|0;c=c|0;ca(0);return 0}function Jk(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(1)}function Kk(a,b){a=a|0;b=b|0;ca(2);return 0.0}function Lk(a,b){a=a|0;b=+b;ca(3)}function Mk(a){a=a|0;ca(4);return 0.0}function Nk(){ca(5);return 0}function Ok(a){a=a|0;ca(6)}function Pk(a,b){a=a|0;b=b|0;ca(7)}function Qk(a){a=a|0;ca(8);return 0}function Rk(a,b,c){a=a|0;b=b|0;c=c|0;ca(9)}function Sk(){ca(10)}function Tk(a,b,c){a=a|0;b=b|0;c=+c;ca(11)}function Uk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(12);return 0}function Vk(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(13)}function Wk(a,b){a=a|0;b=b|0;ca(14);return 0}function Xk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(15)}var Qb=[Ik,Zh,_h,Qj,Qi,Pi,Ri,Ag,sg,qg,rg,yg,kh,jh,Oi,Mj];var Rb=[Jk,ki,ji,gi];var Sb=[Kk,dh];var Tb=[Lk,Wf,Yf,ag];var Ub=[Mk,Xf,Zf,bg];var Vb=[Nk,Nf];var Wb=[Ok,Mh,Nh,Sh,Vh,Th,Uh,Wh,Xh,Yh,Mf,Xg,Yg,Ij,Jj,Ok];var Xb=[Pk,ig,gg,_f,cg,eg,ng,gh];var Yb=[Qk,Oh,Ni,Pf,Vf,Qf,wg,xg,mg,lg,jg,hg,$f,dg,fg,og,fh,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk];var Zb=[Rk,ch];var _b=[Sk];var $b=[Tk,eh,bh,Tk];var ac=[Uk,mh];var bc=[Vk,ni,mi,li];var cc=[Wk,Df,Sf,Tf,Uf,tg,vg,ug,zg,kg,lh,hh,Wk,Wk,Wk,Wk];var dc=[Xk,ai,bi,di];return{_i64Subtract:dk,_fflush:Yi,_i64Add:gk,_memset:ek,_malloc:Uj,_memcpy:ik,___getTypeName:Ah,_bitshift64Lshr:hk,_free:Vj,___errno_location:qi,_bitshift64Shl:fk,__GLOBAL__sub_I_ARToolKitJS_cpp:Wg,__GLOBAL__sub_I_bind_cpp:Ch,runPostSets:ck,stackAlloc:ec,stackSave:fc,stackRestore:gc,establishStackSpace:hc,setThrew:ic,setTempRet0:lc,getTempRet0:mc,dynCall_iiii:sk,dynCall_viiiii:tk,dynCall_dii:uk,dynCall_vid:vk,dynCall_di:wk,dynCall_i:xk,dynCall_vi:yk,dynCall_vii:zk,dynCall_ii:Ak,dynCall_viii:Bk,dynCall_v:Ck,dynCall_viid:Dk,dynCall_iiiii:Ek,dynCall_viiiiii:Fk,dynCall_iii:Gk,dynCall_viiii:Hk}}(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var __GLOBAL__sub_I_bind_cpp=Module["__GLOBAL__sub_I_bind_cpp"]=asm["__GLOBAL__sub_I_bind_cpp"];var _fflush=Module["_fflush"]=asm["_fflush"];var __GLOBAL__sub_I_ARToolKitJS_cpp=Module["__GLOBAL__sub_I_ARToolKitJS_cpp"]=asm["__GLOBAL__sub_I_ARToolKitJS_cpp"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _memset=Module["_memset"]=asm["_memset"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var _malloc=Module["_malloc"]=asm["_malloc"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var ___getTypeName=Module["___getTypeName"]=asm["___getTypeName"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _free=Module["_free"]=asm["_free"];var ___errno_location=Module["___errno_location"]=asm["___errno_location"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_viiiii=Module["dynCall_viiiii"]=asm["dynCall_viiiii"];var dynCall_dii=Module["dynCall_dii"]=asm["dynCall_dii"];var dynCall_vid=Module["dynCall_vid"]=asm["dynCall_vid"];var dynCall_di=Module["dynCall_di"]=asm["dynCall_di"];var dynCall_i=Module["dynCall_i"]=asm["dynCall_i"];var dynCall_vi=Module["dynCall_vi"]=asm["dynCall_vi"];var dynCall_vii=Module["dynCall_vii"]=asm["dynCall_vii"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_viii=Module["dynCall_viii"]=asm["dynCall_viii"];var dynCall_v=Module["dynCall_v"]=asm["dynCall_v"];var dynCall_viid=Module["dynCall_viid"]=asm["dynCall_viid"];var dynCall_iiiii=Module["dynCall_iiiii"]=asm["dynCall_iiiii"];var dynCall_viiiiii=Module["dynCall_viiiiii"]=asm["dynCall_viiiiii"];var dynCall_iii=Module["dynCall_iii"]=asm["dynCall_iii"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];Runtime.stackAlloc=asm["stackAlloc"];Runtime.stackSave=asm["stackSave"];Runtime.stackRestore=asm["stackRestore"];Runtime.establishStackSpace=asm["establishStackSpace"];Runtime.setTempRet0=asm["setTempRet0"];Runtime.getTempRet0=asm["getTempRet0"];function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;var preloadStartTime=null;var calledMain=false;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};Module["callMain"]=Module.callMain=function callMain(args){assert(runDependencies==0,"cannot call main when async dependencies remain! (listen on __ATMAIN__)");assert(__ATPRERUN__.length==0,"cannot call main when preRun functions remain to be called");args=args||[];ensureInitRuntime();var argc=args.length+1;function pad(){for(var i=0;i<4-1;i++){argv.push(0)}}var argv=[allocate(intArrayFromString(Module["thisProgram"]),"i8",ALLOC_NORMAL)];pad();for(var i=0;i0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();if(Module["_main"]&&shouldRunNow)Module["callMain"](args);postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=Module.run=run;function exit(status,implicit){if(implicit&&Module["noExitRuntime"]){return}if(Module["noExitRuntime"]){}else{ABORT=true;EXITSTATUS=status;STACKTOP=initialStackTop;exitRuntime();if(Module["onExit"])Module["onExit"](status)}if(ENVIRONMENT_IS_NODE){process["stdout"]["once"]("drain",function(){process["exit"](status)});console.log(" ");setTimeout(function(){process["exit"](status)},500)}else if(ENVIRONMENT_IS_SHELL&&typeof quit==="function"){quit(status)}throw new ExitStatus(status)}Module["exit"]=Module.exit=exit;var abortDecorators=[];function abort(what){if(what!==undefined){Module.print(what);Module.printErr(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;var extra="\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.";var output="abort("+what+") at "+stackTrace()+extra;if(abortDecorators){abortDecorators.forEach(function(decorator){output=decorator(output,what)})}throw output}Module["abort"]=Module.abort=abort;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}var shouldRunNow=true;if(Module["noInitialRun"]){shouldRunNow=false}run();(function(){"use strict";var ARController=function(width,height,camera){var id;var w=width,h=height;this.orientation="landscape";this.listeners={};if(typeof width!=="number"){var image=width;camera=height;w=image.videoWidth||image.width;h=image.videoHeight||image.height;this.image=image}this.defaultMarkerWidth=1;this.patternMarkers={};this.barcodeMarkers={};this.transform_mat=new Float32Array(16);this.canvas=document.createElement("canvas");this.canvas.width=w;this.canvas.height=h;this.ctx=this.canvas.getContext("2d");this.videoWidth=w;this.videoHeight=h;if(typeof camera==="string"){var self=this;this.cameraParam=new ARCameraParam(camera,function(){self._initialize()},function(err){console.error("ARController: Failed to load ARCameraParam",err)})}else{this.cameraParam=camera;this._initialize()}};ARController.prototype.dispose=function(){artoolkit.teardown(this.id);for(var t in this){this[t]=null}};ARController.prototype.process=function(image){this.detectMarker(image);var markerNum=this.getMarkerNum();var k,o;for(k in this.patternMarkers){o=this.patternMarkers[k];o.inPrevious=o.inCurrent;o.inCurrent=false}for(k in this.barcodeMarkers){o=this.barcodeMarkers[k];o.inPrevious=o.inCurrent;o.inCurrent=false}for(var i=0;i-1&&(markerInfo.id===markerInfo.idPatt||markerInfo.idMatrix===-1)){visible=this.trackPatternMarkerId(markerInfo.idPatt);markerType=artoolkit.PATTERN_MARKER;if(markerInfo.dir!==markerInfo.dirPatt){this.setMarkerInfoDir(i,markerInfo.dirPatt)}}else if(markerInfo.idMatrix>-1){visible=this.trackBarcodeMarkerId(markerInfo.idMatrix);markerType=artoolkit.BARCODE_MARKER;if(markerInfo.dir!==markerInfo.dirMatrix){this.setMarkerInfoDir(i,markerInfo.dirMatrix)}}if(markerType!==artoolkit.UNKNOWN_MARKER&&visible.inPrevious){this.getTransMatSquareCont(i,visible.markerWidth,visible.matrix,visible.matrix)}else{this.getTransMatSquare(i,visible.markerWidth,visible.matrix)}visible.inCurrent=true;this.transMatToGLMat(visible.matrix,this.transform_mat);this.dispatchEvent({name:"getMarker",target:this,data:{index:i,type:markerType,marker:markerInfo,matrix:this.transform_mat}})}var multiMarkerCount=this.getMultiMarkerCount();for(var i=0;i=0){visible=true;this.dispatchEvent({name:"getMultiMarker",target:this,data:{multiMarkerId:i,matrix:this.transform_mat}});break}}if(visible){for(var j=0;j-1){this.listeners[name].splice(index,1)}}};ARController.prototype.dispatchEvent=function(event){var listeners=this.listeners[event.name];if(listeners){for(var i=0;i-1){writeStringToFS(filename,url,writeCallback)}else{ajax(url,filename,writeCallback)}}function writeStringToFS(target,string,callback){var byteArray=new Uint8Array(string.length);for(var i=0;i=this.parameters.minVisibleDelay){object3d.visible=true;snapDirectlyToTarget()}}if(wasVisible===true&&targetObject3d.visible===false){var unvisibleFor=present-this._unvisibleStartedAt;if(unvisibleFor>=this.parameters.minUnvisibleDelay){object3d.visible=false}}if(this._lastLerpStepAt===null){applyOneSlerpStep();this._lastLerpStepAt=present}else{var nStepsToDo=Math.floor((present-this._lastLerpStepAt)/this.parameters.lerpStepDelay);for(var i=0;iwebvr.info for more info."); -}else{alert("Your browser does not support WebVR. See webvr.info for assistance.")}this._tangoContext={vrDisplay:null,vrPointCloud:null,frameData:new VRFrameData};navigator.getVRDisplays().then(function(vrDisplays){if(vrDisplays.length===0)alert("no vrDisplays available");var vrDisplay=_this._tangoContext.vrDisplay=vrDisplays[0];console.log("vrDisplays.displayName :",vrDisplay.displayName);if(vrDisplay.displayName==="Tango VR Device"){_this._tangoContext.vrPointCloud=new THREE.WebAR.VRPointCloud(vrDisplay,true)}onCompleted()})};THREEx.ArToolkitContext.prototype._updateTango=function(srcElement){var _this=this;var arMarkersControls=this._arMarkersControls;var tangoContext=this._tangoContext;var vrDisplay=this._tangoContext.vrDisplay;if(vrDisplay===null)return;if(vrDisplay.displayName==="Tango VR Device"){var showPointCloud=true;var pointsToSkip=0;_this._tangoContext.vrPointCloud.update(showPointCloud,pointsToSkip,true)}if(this._arMarkersControls.length===0)return;var foundControls=this._arMarkersControls[0];var frameData=this._tangoContext.frameData;vrDisplay.getFrameData(frameData);if(frameData.pose.position===null)return;if(frameData.pose.orientation===null)return;var position=(new THREE.Vector3).fromArray(frameData.pose.position);var quaternion=(new THREE.Quaternion).fromArray(frameData.pose.orientation);var scale=new THREE.Vector3(1,1,1);var cameraTransformMatrix=(new THREE.Matrix4).compose(position,quaternion,scale);var modelViewMatrix=new THREE.Matrix4;modelViewMatrix.getInverse(cameraTransformMatrix);foundControls.updateWithModelViewMatrix(modelViewMatrix)};var ARjs=ARjs||{};var THREEx=THREEx||{};ARjs.Profile=THREEx.ArToolkitProfile=function(){this.reset();this.performance("default")};ARjs.Profile.prototype._guessPerformanceLabel=function(){var isMobile=navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i)?true:false;if(isMobile===true){return"phone-normal"}return"desktop-normal"};ARjs.Profile.prototype.reset=function(){this.sourceParameters={sourceType:"webcam"};this.contextParameters={cameraParametersUrl:THREEx.ArToolkitContext.baseURL+"../data/data/camera_para.dat",detectionMode:"mono"};this.defaultMarkerParameters={type:"pattern",patternUrl:THREEx.ArToolkitContext.baseURL+"../data/data/patt.hiro",changeMatrixMode:"modelViewMatrix"};return this};ARjs.Profile.prototype.performance=function(label){if(label==="default"){label=this._guessPerformanceLabel()}if(label==="desktop-fast"){this.contextParameters.canvasWidth=640*3;this.contextParameters.canvasHeight=480*3;this.contextParameters.maxDetectionRate=30}else if(label==="desktop-normal"){this.contextParameters.canvasWidth=640;this.contextParameters.canvasHeight=480;this.contextParameters.maxDetectionRate=60}else if(label==="phone-normal"){this.contextParameters.canvasWidth=80*4;this.contextParameters.canvasHeight=60*4;this.contextParameters.maxDetectionRate=30}else if(label==="phone-slow"){this.contextParameters.canvasWidth=80*3;this.contextParameters.canvasHeight=60*3;this.contextParameters.maxDetectionRate=30}else{console.assert(false,"unknonwn label "+label)}return this};ARjs.Profile.prototype.defaultMarker=function(trackingBackend){trackingBackend=trackingBackend||this.contextParameters.trackingBackend;if(trackingBackend==="artoolkit"){this.contextParameters.detectionMode="mono";this.defaultMarkerParameters.type="pattern";this.defaultMarkerParameters.patternUrl=THREEx.ArToolkitContext.baseURL+"../data/data/patt.hiro"}else if(trackingBackend==="aruco"){this.contextParameters.detectionMode="mono";this.defaultMarkerParameters.type="barcode";this.defaultMarkerParameters.barcodeValue=1001}else if(trackingBackend==="tango"){this.defaultMarkerParameters.type="barcode";this.defaultMarkerParameters.barcodeValue=1001}else console.assert(false);return this};ARjs.Profile.prototype.sourceWebcam=function(){this.sourceParameters.sourceType="webcam";delete this.sourceParameters.sourceUrl;return this};ARjs.Profile.prototype.sourceVideo=function(url){this.sourceParameters.sourceType="video";this.sourceParameters.sourceUrl=url;return this};ARjs.Profile.prototype.sourceImage=function(url){this.sourceParameters.sourceType="image";this.sourceParameters.sourceUrl=url;return this};ARjs.Profile.prototype.trackingBackend=function(trackingBackend){console.warn("stop profile.trackingBackend() obsolete function. use .trackingMethod instead");this.contextParameters.trackingBackend=trackingBackend;return this};ARjs.Profile.prototype.changeMatrixMode=function(changeMatrixMode){this.defaultMarkerParameters.changeMatrixMode=changeMatrixMode;return this};ARjs.Profile.prototype.trackingMethod=function(trackingMethod){var data=ARjs.Utils.parseTrackingMethod(trackingMethod);this.defaultMarkerParameters.markersAreaEnabled=data.markersAreaEnabled;this.contextParameters.trackingBackend=data.trackingBackend;return this};ARjs.Profile.prototype.checkIfValid=function(){if(this.contextParameters.trackingBackend==="tango"){this.sourceImage(THREEx.ArToolkitContext.baseURL+"../data/images/img.jpg")}return this};var THREEx=THREEx||{};THREEx.ArToolkitSource=function(parameters){this.parameters={sourceType:parameters.sourceType!==undefined?parameters.sourceType:"webcam",sourceUrl:parameters.sourceUrl!==undefined?parameters.sourceUrl:null,sourceWidth:parameters.sourceWidth!==undefined?parameters.sourceWidth:640,sourceHeight:parameters.sourceHeight!==undefined?parameters.sourceHeight:480,displayWidth:parameters.displayWidth!==undefined?parameters.displayWidth:640,displayHeight:parameters.displayHeight!==undefined?parameters.displayHeight:480};this.ready=false;this.domElement=null};THREEx.ArToolkitSource.prototype.init=function(onReady){var _this=this;if(this.parameters.sourceType==="image"){var domElement=this._initSourceImage(onSourceReady)}else if(this.parameters.sourceType==="video"){var domElement=this._initSourceVideo(onSourceReady)}else if(this.parameters.sourceType==="webcam"){var domElement=this._initSourceWebcam(onSourceReady)}else{console.assert(false)}this.domElement=domElement;this.domElement.style.position="absolute";this.domElement.style.top="0px";this.domElement.style.left="0px";this.domElement.style.zIndex="-2";return this;function onSourceReady(){document.body.appendChild(_this.domElement);_this.ready=true;onReady&&onReady()}};THREEx.ArToolkitSource.prototype._initSourceImage=function(onReady){var domElement=document.createElement("img");domElement.src=this.parameters.sourceUrl;domElement.width=this.parameters.sourceWidth;domElement.height=this.parameters.sourceHeight;domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";var interval=setInterval(function(){if(!domElement.naturalWidth)return;onReady();clearInterval(interval)},1e3/50);return domElement};THREEx.ArToolkitSource.prototype._initSourceVideo=function(onReady){var domElement=document.createElement("video");domElement.src=this.parameters.sourceUrl;domElement.style.objectFit="initial";domElement.autoplay=true;domElement.webkitPlaysinline=true;domElement.controls=false;domElement.loop=true;domElement.muted=true;document.body.addEventListener("click",function onClick(){document.body.removeEventListener("click",onClick);domElement.play()});domElement.width=this.parameters.sourceWidth;domElement.height=this.parameters.sourceHeight;domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";var interval=setInterval(function(){if(!domElement.videoWidth)return;onReady();clearInterval(interval)},1e3/50);return domElement};THREEx.ArToolkitSource.prototype._initSourceWebcam=function(onReady){var _this=this;var domElement=document.createElement("video");domElement.setAttribute("autoplay","");domElement.setAttribute("muted","");domElement.setAttribute("playsinline","");domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";if(navigator.mediaDevices===undefined||navigator.mediaDevices.enumerateDevices===undefined||navigator.mediaDevices.getUserMedia===undefined){alert("WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser")}navigator.mediaDevices.enumerateDevices().then(function(devices){var userMediaConstraints={audio:false,video:{facingMode:"environment",width:{ideal:_this.parameters.sourceWidth},height:{ideal:_this.parameters.sourceHeight}}};navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream){domElement.srcObject=stream;document.body.addEventListener("click",function(){domElement.play()});var interval=setInterval(function(){if(!domElement.videoWidth)return;onReady();clearInterval(interval)},1e3/50)}).catch(function(error){console.log("Can't access user media",error);alert("Can't access user media :()")})}).catch(function(err){console.log(err.name+": "+err.message)});return domElement};THREEx.ArToolkitSource.prototype.hasMobileTorch=function(){var stream=arToolkitSource.domElement.srcObject;if(stream instanceof MediaStream===false)return false;if(this._currentTorchStatus===undefined){this._currentTorchStatus=false}var videoTrack=stream.getVideoTracks()[0];if(videoTrack.getCapabilities===undefined)return false;var capabilities=videoTrack.getCapabilities();return capabilities.torch?true:false};THREEx.ArToolkitSource.prototype.toggleMobileTorch=function(){console.assert(this.hasMobileTorch()===true);var stream=arToolkitSource.domElement.srcObject;if(stream instanceof MediaStream===false){alert("enabling mobile torch is available only on webcam");return}if(this._currentTorchStatus===undefined){this._currentTorchStatus=false}var videoTrack=stream.getVideoTracks()[0];var capabilities=videoTrack.getCapabilities();if(!capabilities.torch){alert("no mobile torch is available on your camera");return}this._currentTorchStatus=this._currentTorchStatus===false?true:false;videoTrack.applyConstraints({advanced:[{torch:this._currentTorchStatus}]}).catch(function(error){console.log(error)})};THREEx.ArToolkitSource.prototype.onResizeElement=function(mirrorDomElements){var _this=this;var screenWidth=window.innerWidth;var screenHeight=window.innerHeight;if(this.domElement.nodeName==="IMG"){var sourceWidth=this.domElement.naturalWidth;var sourceHeight=this.domElement.naturalHeight}else if(this.domElement.nodeName==="VIDEO"){var sourceWidth=this.domElement.videoWidth;var sourceHeight=this.domElement.videoHeight}else{console.assert(false)}var sourceAspect=sourceWidth/sourceHeight;var screenAspect=screenWidth/screenHeight;if(screenAspect3)console.assert("wrong api for",THREEx.ArMultiMarkerControls);this.parameters={subMarkersControls:parameters.subMarkersControls,subMarkerPoses:parameters.subMarkerPoses,changeMatrixMode:parameters.changeMatrixMode!==undefined?parameters.changeMatrixMode:"modelViewMatrix"};this.object3d.visible=false;this.subMarkersControls=this.parameters.subMarkersControls;this.subMarkerPoses=this.parameters.subMarkerPoses;arToolkitContext.addEventListener("sourceProcessed",function(){_this._onSourceProcessed()})};THREEx.ArMultiMarkerControls.prototype=Object.create(THREEx.ArBaseControls.prototype);THREEx.ArMultiMarkerControls.prototype.constructor=THREEx.ArMultiMarkerControls;THREEx.ArMultiMarkerControls.prototype._onSourceProcessed=function(){var _this=this;var stats={count:0,position:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)},quaternion:{sum:new THREE.Quaternion(0,0,0,0),average:new THREE.Quaternion(0,0,0,0)},scale:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)}};var firstQuaternion=_this.parameters.subMarkersControls[0].object3d.quaternion;this.parameters.subMarkersControls.forEach(function(markerControls,markerIndex){var markerObject3d=markerControls.object3d;if(markerObject3d.visible===false)return;var matrix=markerObject3d.matrix.clone();var markerPose=_this.parameters.subMarkerPoses[markerIndex];matrix.multiply((new THREE.Matrix4).getInverse(markerPose));var position=new THREE.Vector3;var quaternion=new THREE.Quaternion;var scale=new THREE.Vector3;matrix.decompose(position,quaternion,scale);stats.count++;THREEx.ArMultiMarkerControls.averageVector3(stats.position.sum,position,stats.count,stats.position.average);THREEx.ArMultiMarkerControls.averageQuaternion(stats.quaternion.sum,quaternion,firstQuaternion,stats.count,stats.quaternion.average);THREEx.ArMultiMarkerControls.averageVector3(stats.scale.sum,scale,stats.count,stats.scale.average)});if(stats.count>0){_this.object3d.visible=true}else{_this.object3d.visible=false}if(stats.count>0){var modelViewMatrix=new THREE.Matrix4;modelViewMatrix.compose(stats.position.average,stats.quaternion.average,stats.scale.average);if(this.parameters.changeMatrixMode==="modelViewMatrix"){_this.object3d.matrix.copy(modelViewMatrix)}else if(this.parameters.changeMatrixMode==="cameraTransformMatrix"){_this.object3d.matrix.getInverse(modelViewMatrix)}else{console.assert(false)}_this.object3d.matrix.decompose(_this.object3d.position,_this.object3d.quaternion,_this.object3d.scale)}};THREEx.ArMultiMarkerControls.averageQuaternion=function(quaternionSum,newQuaternion,firstQuaternion,count,quaternionAverage){quaternionAverage=quaternionAverage||new THREE.Quaternion;console.assert(firstQuaternion instanceof THREE.Quaternion===true);if(newQuaternion.dot(firstQuaternion)>0){newQuaternion=new THREE.Quaternion(-newQuaternion.x,-newQuaternion.y,-newQuaternion.z,-newQuaternion.w)}quaternionSum.x+=newQuaternion.x;quaternionSum.y+=newQuaternion.y;quaternionSum.z+=newQuaternion.z;quaternionSum.w+=newQuaternion.w;quaternionAverage.x=quaternionSum.x/count;quaternionAverage.y=quaternionSum.y/count;quaternionAverage.z=quaternionSum.z/count;quaternionAverage.w=quaternionSum.w/count;quaternionAverage.normalize();return quaternionAverage};THREEx.ArMultiMarkerControls.averageVector3=function(vector3Sum,vector3,count,vector3Average){vector3Average=vector3Average||new THREE.Vector3;vector3Sum.x+=vector3.x;vector3Sum.y+=vector3.y;vector3Sum.z+=vector3.z;vector3Average.x=vector3Sum.x/count;vector3Average.y=vector3Sum.y/count;vector3Average.z=vector3Sum.z/count;return vector3Average};THREEx.ArMultiMarkerControls.computeCenter=function(jsonData){var multiMarkerFile=JSON.parse(jsonData);var stats={count:0,position:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)},quaternion:{sum:new THREE.Quaternion(0,0,0,0),average:new THREE.Quaternion(0,0,0,0)},scale:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)}};var firstQuaternion=new THREE.Quaternion;multiMarkerFile.subMarkersControls.forEach(function(item){var poseMatrix=(new THREE.Matrix4).fromArray(item.poseMatrix);var position=new THREE.Vector3;var quaternion=new THREE.Quaternion;var scale=new THREE.Vector3;poseMatrix.decompose(position,quaternion,scale);stats.count++;THREEx.ArMultiMarkerControls.averageVector3(stats.position.sum,position,stats.count,stats.position.average);THREEx.ArMultiMarkerControls.averageQuaternion(stats.quaternion.sum,quaternion,firstQuaternion,stats.count,stats.quaternion.average);THREEx.ArMultiMarkerControls.averageVector3(stats.scale.sum,scale,stats.count,stats.scale.average)});var averageMatrix=new THREE.Matrix4;averageMatrix.compose(stats.position.average,stats.quaternion.average,stats.scale.average);return averageMatrix};THREEx.ArMultiMarkerControls.computeBoundingBox=function(jsonData){var multiMarkerFile=JSON.parse(jsonData);var boundingBox=new THREE.Box3;multiMarkerFile.subMarkersControls.forEach(function(item){var poseMatrix=(new THREE.Matrix4).fromArray(item.poseMatrix);var position=new THREE.Vector3;var quaternion=new THREE.Quaternion;var scale=new THREE.Vector3;poseMatrix.decompose(position,quaternion,scale);boundingBox.expandByPoint(position)});return boundingBox};THREEx.ArMultiMarkerControls.prototype.updateSmoothedControls=function(smoothedControls,lerpsValues){if(lerpsValues===undefined){lerpsValues=[[.1,.1,.3],[.2,.1,.4],[.2,.2,.5],[.3,.2,.7],[.3,.2,.7]]}var nVisible=0;this.parameters.subMarkersControls.forEach(function(markerControls,markerIndex){var markerObject3d=markerControls.object3d;if(markerObject3d.visible===true)nVisible++});if(lerpsValues[nVisible-1]!==undefined){var lerpValues=lerpsValues[nVisible-1]}else{var lerpValues=lerpsValues[lerpsValues.length-1]}smoothedControls.parameters.lerpPosition=lerpValues[0];smoothedControls.parameters.lerpQuaternion=lerpValues[1];smoothedControls.parameters.lerpScale=lerpValues[2]};THREEx.ArMultiMarkerControls.fromJSON=function(arToolkitContext,parent3D,markerRoot,jsonData,parameters){var multiMarkerFile=JSON.parse(jsonData);var subMarkersControls=[];var subMarkerPoses=[];parameters=parameters||{};multiMarkerFile.subMarkersControls.forEach(function(item){var markerRoot=new THREE.Object3D;parent3D.add(markerRoot);var subMarkerControls=new THREEx.ArMarkerControls(arToolkitContext,markerRoot,item.parameters);subMarkersControls.push(subMarkerControls);subMarkerPoses.push((new THREE.Matrix4).fromArray(item.poseMatrix))});parameters.subMarkersControls=subMarkersControls;parameters.subMarkerPoses=subMarkerPoses;var multiMarkerControls=new THREEx.ArMultiMarkerControls(arToolkitContext,markerRoot,parameters);return multiMarkerControls};var THREEx=THREEx||{};THREEx.ArMultiMakersLearning=function(arToolkitContext,subMarkersControls){var _this=this;this._arToolkitContext=arToolkitContext;this.subMarkersControls=subMarkersControls;this.enabled=true;arToolkitContext.addEventListener("sourceProcessed",function(){_this._onSourceProcessed()})};THREEx.ArMultiMakersLearning.prototype._onSourceProcessed=function(){var originQuaternion=this.subMarkersControls[0].object3d.quaternion;if(this.enabled===false)return;var visibleMarkerControls=this.subMarkersControls.filter(function(markerControls){return markerControls.object3d.visible===true});var count=Object.keys(visibleMarkerControls).length;var positionDelta=new THREE.Vector3;var quaternionDelta=new THREE.Quaternion;var scaleDelta=new THREE.Vector3;var tmpMatrix=new THREE.Matrix4;for(var i=0;i=1?true:false;if(isLearned===true)return;var otherSubControlsID=_this._getLearnedCoupleStats(subMarkerControls);if(otherSubControlsID===null){return}var otherSubControls=_this._getSubMarkerControlsByID(otherSubControlsID);var seenCoupleStats=subMarkerControls.object3d.userData.seenCouples[otherSubControlsID];var averageMatrix=new THREE.Matrix4;averageMatrix.compose(seenCoupleStats.position.average,seenCoupleStats.quaternion.average,seenCoupleStats.scale.average);var otherAverageMatrix=otherSubControls.object3d.userData.result.averageMatrix;var matrix=(new THREE.Matrix4).getInverse(otherAverageMatrix).multiply(averageMatrix);matrix=(new THREE.Matrix4).getInverse(matrix);console.assert(subMarkerControls.object3d.userData.result===undefined);subMarkerControls.object3d.userData.result={averageMatrix:matrix,confidenceFactor:1};resultChanged=true})}while(resultChanged===true)};THREEx.ArMultiMakersLearning.prototype._getLearnedCoupleStats=function(subMarkerControls){if(subMarkerControls.object3d.userData.seenCouples===undefined)return null;var seenCouples=subMarkerControls.object3d.userData.seenCouples;var coupleControlsIDs=Object.keys(seenCouples).map(Number);for(var i=0;i=1?true:false;if(isLearned===false)continue;return otherSubControlsID}return null};THREEx.ArMultiMakersLearning.prototype._getSubMarkerControlsByID=function(controlsID){for(var i=0;i-1){writeStringToFS(filename,url,writeCallback)}else{ajax(url,filename,writeCallback)}}function writeStringToFS(target,string,callback){var byteArray=new Uint8Array(string.length);for(var i=0;i=this.parameters.minVisibleDelay){object3d.visible=true;snapDirectlyToTarget()}}if(wasVisible===true&&targetObject3d.visible===false){var unvisibleFor=present-this._unvisibleStartedAt;if(unvisibleFor>=this.parameters.minUnvisibleDelay){object3d.visible=false}}if(this._lastLerpStepAt===null){applyOneSlerpStep();this._lastLerpStepAt=present}else{var nStepsToDo=Math.floor((present-this._lastLerpStepAt)/this.parameters.lerpStepDelay);for(var i=0;iwebvr.info for more info.")}else{alert("Your browser does not support WebVR. See webvr.info for assistance."); +}this._tangoContext={vrDisplay:null,vrPointCloud:null,frameData:new VRFrameData};navigator.getVRDisplays().then(function(vrDisplays){if(vrDisplays.length===0)alert("no vrDisplays available");var vrDisplay=_this._tangoContext.vrDisplay=vrDisplays[0];console.log("vrDisplays.displayName :",vrDisplay.displayName);if(vrDisplay.displayName==="Tango VR Device"){_this._tangoContext.vrPointCloud=new THREE.WebAR.VRPointCloud(vrDisplay,true)}onCompleted()})};ARjs.Context.prototype._updateTango=function(srcElement){var _this=this;var arMarkersControls=this._arMarkersControls;var tangoContext=this._tangoContext;var vrDisplay=this._tangoContext.vrDisplay;if(vrDisplay===null)return;if(vrDisplay.displayName==="Tango VR Device"){var showPointCloud=true;var pointsToSkip=0;_this._tangoContext.vrPointCloud.update(showPointCloud,pointsToSkip,true)}if(this._arMarkersControls.length===0)return;var foundControls=this._arMarkersControls[0];var frameData=this._tangoContext.frameData;vrDisplay.getFrameData(frameData);if(frameData.pose.position===null)return;if(frameData.pose.orientation===null)return;var position=(new THREE.Vector3).fromArray(frameData.pose.position);var quaternion=(new THREE.Quaternion).fromArray(frameData.pose.orientation);var scale=new THREE.Vector3(1,1,1);var cameraTransformMatrix=(new THREE.Matrix4).compose(position,quaternion,scale);var modelViewMatrix=new THREE.Matrix4;modelViewMatrix.getInverse(cameraTransformMatrix);foundControls.updateWithModelViewMatrix(modelViewMatrix)};var ARjs=ARjs||{};var THREEx=THREEx||{};ARjs.Profile=THREEx.ArToolkitProfile=function(){this.reset();this.performance("default")};ARjs.Profile.prototype._guessPerformanceLabel=function(){var isMobile=navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i)?true:false;if(isMobile===true){return"phone-normal"}return"desktop-normal"};ARjs.Profile.prototype.reset=function(){this.sourceParameters={sourceType:"webcam"};this.contextParameters={cameraParametersUrl:THREEx.ArToolkitContext.baseURL+"../data/data/camera_para.dat",detectionMode:"mono"};this.defaultMarkerParameters={type:"pattern",patternUrl:THREEx.ArToolkitContext.baseURL+"../data/data/patt.hiro",changeMatrixMode:"modelViewMatrix"};return this};ARjs.Profile.prototype.performance=function(label){if(label==="default"){label=this._guessPerformanceLabel()}if(label==="desktop-fast"){this.contextParameters.canvasWidth=640*3;this.contextParameters.canvasHeight=480*3;this.contextParameters.maxDetectionRate=30}else if(label==="desktop-normal"){this.contextParameters.canvasWidth=640;this.contextParameters.canvasHeight=480;this.contextParameters.maxDetectionRate=60}else if(label==="phone-normal"){this.contextParameters.canvasWidth=80*4;this.contextParameters.canvasHeight=60*4;this.contextParameters.maxDetectionRate=30}else if(label==="phone-slow"){this.contextParameters.canvasWidth=80*3;this.contextParameters.canvasHeight=60*3;this.contextParameters.maxDetectionRate=30}else{console.assert(false,"unknonwn label "+label)}return this};ARjs.Profile.prototype.defaultMarker=function(trackingBackend){trackingBackend=trackingBackend||this.contextParameters.trackingBackend;if(trackingBackend==="artoolkit"){this.contextParameters.detectionMode="mono";this.defaultMarkerParameters.type="pattern";this.defaultMarkerParameters.patternUrl=THREEx.ArToolkitContext.baseURL+"../data/data/patt.hiro"}else if(trackingBackend==="aruco"){this.contextParameters.detectionMode="mono";this.defaultMarkerParameters.type="barcode";this.defaultMarkerParameters.barcodeValue=1001}else if(trackingBackend==="tango"){this.defaultMarkerParameters.type="barcode";this.defaultMarkerParameters.barcodeValue=1001}else console.assert(false);return this};ARjs.Profile.prototype.sourceWebcam=function(){this.sourceParameters.sourceType="webcam";delete this.sourceParameters.sourceUrl;return this};ARjs.Profile.prototype.sourceVideo=function(url){this.sourceParameters.sourceType="video";this.sourceParameters.sourceUrl=url;return this};ARjs.Profile.prototype.sourceImage=function(url){this.sourceParameters.sourceType="image";this.sourceParameters.sourceUrl=url;return this};ARjs.Profile.prototype.trackingBackend=function(trackingBackend){console.warn("stop profile.trackingBackend() obsolete function. use .trackingMethod instead");this.contextParameters.trackingBackend=trackingBackend;return this};ARjs.Profile.prototype.changeMatrixMode=function(changeMatrixMode){this.defaultMarkerParameters.changeMatrixMode=changeMatrixMode;return this};ARjs.Profile.prototype.trackingMethod=function(trackingMethod){var data=ARjs.Utils.parseTrackingMethod(trackingMethod);this.defaultMarkerParameters.markersAreaEnabled=data.markersAreaEnabled;this.contextParameters.trackingBackend=data.trackingBackend;return this};ARjs.Profile.prototype.checkIfValid=function(){if(this.contextParameters.trackingBackend==="tango"){this.sourceImage(THREEx.ArToolkitContext.baseURL+"../data/images/img.jpg")}return this};var ARjs=ARjs||{};var THREEx=THREEx||{};ARjs.Source=THREEx.ArToolkitSource=function(parameters){var _this=this;this.ready=false;this.domElement=null;this.parameters={sourceType:"webcam",sourceUrl:null,sourceWidth:640,sourceHeight:480,displayWidth:640,displayHeight:480};setParameters(parameters);function setParameters(parameters){if(parameters===undefined)return;for(var key in parameters){var newValue=parameters[key];if(newValue===undefined){console.warn("THREEx.ArToolkitSource: '"+key+"' parameter is undefined.");continue}var currentValue=_this.parameters[key];if(currentValue===undefined){console.warn("THREEx.ArToolkitSource: '"+key+"' is not a property of this material.");continue}_this.parameters[key]=newValue}}};ARjs.Source.prototype.init=function(onReady,onError){var _this=this;if(this.parameters.sourceType==="image"){var domElement=this._initSourceImage(onSourceReady,onError)}else if(this.parameters.sourceType==="video"){var domElement=this._initSourceVideo(onSourceReady,onError)}else if(this.parameters.sourceType==="webcam"){var domElement=this._initSourceWebcam(onSourceReady,onError)}else{console.assert(false)}this.domElement=domElement;this.domElement.style.position="absolute";this.domElement.style.top="0px";this.domElement.style.left="0px";this.domElement.style.zIndex="-2";return this;function onSourceReady(){document.body.appendChild(_this.domElement);_this.ready=true;onReady&&onReady()}};ARjs.Source.prototype._initSourceImage=function(onReady){var domElement=document.createElement("img");domElement.src=this.parameters.sourceUrl;domElement.width=this.parameters.sourceWidth;domElement.height=this.parameters.sourceHeight;domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";var interval=setInterval(function(){if(!domElement.naturalWidth)return;onReady();clearInterval(interval)},1e3/50);return domElement};ARjs.Source.prototype._initSourceVideo=function(onReady){var domElement=document.createElement("video");domElement.src=this.parameters.sourceUrl;domElement.style.objectFit="initial";domElement.autoplay=true;domElement.webkitPlaysinline=true;domElement.controls=false;domElement.loop=true;domElement.muted=true;document.body.addEventListener("click",function onClick(){document.body.removeEventListener("click",onClick);domElement.play()});domElement.width=this.parameters.sourceWidth;domElement.height=this.parameters.sourceHeight;domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";var interval=setInterval(function(){if(!domElement.videoWidth)return;onReady();clearInterval(interval)},1e3/50);return domElement};ARjs.Source.prototype._initSourceWebcam=function(onReady,onError){var _this=this;onError=onError||function(error){alert("Webcam Error\nName: "+error.name+"\nMessage: "+error.message)};var domElement=document.createElement("video");domElement.setAttribute("autoplay","");domElement.setAttribute("muted","");domElement.setAttribute("playsinline","");domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";if(navigator.mediaDevices===undefined||navigator.mediaDevices.enumerateDevices===undefined||navigator.mediaDevices.getUserMedia===undefined){onError({name:"",message:"WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser"});return}navigator.mediaDevices.enumerateDevices().then(function(devices){var userMediaConstraints={audio:false,video:{facingMode:"environment",width:{ideal:_this.parameters.sourceWidth},height:{ideal:_this.parameters.sourceHeight}}};navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream){domElement.srcObject=stream;document.body.addEventListener("click",function(){domElement.play()});var interval=setInterval(function(){if(!domElement.videoWidth)return;onReady();clearInterval(interval)},1e3/50)}).catch(function(error){onError({name:error.name,message:error.message})})}).catch(function(error){onError({message:error.message})});return domElement};ARjs.Source.prototype.hasMobileTorch=function(){var stream=arToolkitSource.domElement.srcObject;if(stream instanceof MediaStream===false)return false;if(this._currentTorchStatus===undefined){this._currentTorchStatus=false}var videoTrack=stream.getVideoTracks()[0];if(videoTrack.getCapabilities===undefined)return false;var capabilities=videoTrack.getCapabilities();return capabilities.torch?true:false};ARjs.Source.prototype.toggleMobileTorch=function(){console.assert(this.hasMobileTorch()===true);var stream=arToolkitSource.domElement.srcObject;if(stream instanceof MediaStream===false){alert("enabling mobile torch is available only on webcam");return}if(this._currentTorchStatus===undefined){this._currentTorchStatus=false}var videoTrack=stream.getVideoTracks()[0];var capabilities=videoTrack.getCapabilities();if(!capabilities.torch){alert("no mobile torch is available on your camera");return}this._currentTorchStatus=this._currentTorchStatus===false?true:false;videoTrack.applyConstraints({advanced:[{torch:this._currentTorchStatus}]}).catch(function(error){console.log(error)})};ARjs.Source.prototype.onResizeElement=function(mirrorDomElements){var _this=this;var screenWidth=window.innerWidth;var screenHeight=window.innerHeight;if(this.domElement.nodeName==="IMG"){var sourceWidth=this.domElement.naturalWidth;var sourceHeight=this.domElement.naturalHeight}else if(this.domElement.nodeName==="VIDEO"){var sourceWidth=this.domElement.videoWidth;var sourceHeight=this.domElement.videoHeight}else{console.assert(false)}var sourceAspect=sourceWidth/sourceHeight;var screenAspect=screenWidth/screenHeight;if(screenAspect3)console.assert("wrong api for",THREEx.ArMultiMarkerControls);this.parameters={subMarkersControls:parameters.subMarkersControls,subMarkerPoses:parameters.subMarkerPoses,changeMatrixMode:parameters.changeMatrixMode!==undefined?parameters.changeMatrixMode:"modelViewMatrix"};this.object3d.visible=false;this.subMarkersControls=this.parameters.subMarkersControls;this.subMarkerPoses=this.parameters.subMarkerPoses;arToolkitContext.addEventListener("sourceProcessed",function(){_this._onSourceProcessed()})};THREEx.ArMultiMarkerControls.prototype=Object.create(THREEx.ArBaseControls.prototype);THREEx.ArMultiMarkerControls.prototype.constructor=THREEx.ArMultiMarkerControls;THREEx.ArMultiMarkerControls.prototype._onSourceProcessed=function(){var _this=this;var stats={count:0,position:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)},quaternion:{sum:new THREE.Quaternion(0,0,0,0),average:new THREE.Quaternion(0,0,0,0)},scale:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)}};var firstQuaternion=_this.parameters.subMarkersControls[0].object3d.quaternion;this.parameters.subMarkersControls.forEach(function(markerControls,markerIndex){var markerObject3d=markerControls.object3d;if(markerObject3d.visible===false)return;var matrix=markerObject3d.matrix.clone();var markerPose=_this.parameters.subMarkerPoses[markerIndex];matrix.multiply((new THREE.Matrix4).getInverse(markerPose));var position=new THREE.Vector3;var quaternion=new THREE.Quaternion;var scale=new THREE.Vector3;matrix.decompose(position,quaternion,scale);stats.count++;THREEx.ArMultiMarkerControls.averageVector3(stats.position.sum,position,stats.count,stats.position.average);THREEx.ArMultiMarkerControls.averageQuaternion(stats.quaternion.sum,quaternion,firstQuaternion,stats.count,stats.quaternion.average);THREEx.ArMultiMarkerControls.averageVector3(stats.scale.sum,scale,stats.count,stats.scale.average)});if(stats.count>0){_this.object3d.visible=true}else{_this.object3d.visible=false}if(stats.count>0){var modelViewMatrix=new THREE.Matrix4;modelViewMatrix.compose(stats.position.average,stats.quaternion.average,stats.scale.average);if(this.parameters.changeMatrixMode==="modelViewMatrix"){_this.object3d.matrix.copy(modelViewMatrix)}else if(this.parameters.changeMatrixMode==="cameraTransformMatrix"){_this.object3d.matrix.getInverse(modelViewMatrix)}else{console.assert(false)}_this.object3d.matrix.decompose(_this.object3d.position,_this.object3d.quaternion,_this.object3d.scale)}};THREEx.ArMultiMarkerControls.averageQuaternion=function(quaternionSum,newQuaternion,firstQuaternion,count,quaternionAverage){quaternionAverage=quaternionAverage||new THREE.Quaternion;console.assert(firstQuaternion instanceof THREE.Quaternion===true);if(newQuaternion.dot(firstQuaternion)>0){newQuaternion=new THREE.Quaternion(-newQuaternion.x,-newQuaternion.y,-newQuaternion.z,-newQuaternion.w)}quaternionSum.x+=newQuaternion.x;quaternionSum.y+=newQuaternion.y;quaternionSum.z+=newQuaternion.z;quaternionSum.w+=newQuaternion.w;quaternionAverage.x=quaternionSum.x/count;quaternionAverage.y=quaternionSum.y/count;quaternionAverage.z=quaternionSum.z/count;quaternionAverage.w=quaternionSum.w/count;quaternionAverage.normalize();return quaternionAverage};THREEx.ArMultiMarkerControls.averageVector3=function(vector3Sum,vector3,count,vector3Average){vector3Average=vector3Average||new THREE.Vector3;vector3Sum.x+=vector3.x;vector3Sum.y+=vector3.y;vector3Sum.z+=vector3.z;vector3Average.x=vector3Sum.x/count;vector3Average.y=vector3Sum.y/count;vector3Average.z=vector3Sum.z/count;return vector3Average};THREEx.ArMultiMarkerControls.computeCenter=function(jsonData){var multiMarkerFile=JSON.parse(jsonData);var stats={count:0,position:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)},quaternion:{sum:new THREE.Quaternion(0,0,0,0),average:new THREE.Quaternion(0,0,0,0)},scale:{sum:new THREE.Vector3(0,0,0),average:new THREE.Vector3(0,0,0)}};var firstQuaternion=new THREE.Quaternion;multiMarkerFile.subMarkersControls.forEach(function(item){var poseMatrix=(new THREE.Matrix4).fromArray(item.poseMatrix);var position=new THREE.Vector3;var quaternion=new THREE.Quaternion;var scale=new THREE.Vector3;poseMatrix.decompose(position,quaternion,scale);stats.count++;THREEx.ArMultiMarkerControls.averageVector3(stats.position.sum,position,stats.count,stats.position.average);THREEx.ArMultiMarkerControls.averageQuaternion(stats.quaternion.sum,quaternion,firstQuaternion,stats.count,stats.quaternion.average);THREEx.ArMultiMarkerControls.averageVector3(stats.scale.sum,scale,stats.count,stats.scale.average)});var averageMatrix=new THREE.Matrix4;averageMatrix.compose(stats.position.average,stats.quaternion.average,stats.scale.average);return averageMatrix};THREEx.ArMultiMarkerControls.computeBoundingBox=function(jsonData){var multiMarkerFile=JSON.parse(jsonData);var boundingBox=new THREE.Box3;multiMarkerFile.subMarkersControls.forEach(function(item){var poseMatrix=(new THREE.Matrix4).fromArray(item.poseMatrix);var position=new THREE.Vector3;var quaternion=new THREE.Quaternion;var scale=new THREE.Vector3;poseMatrix.decompose(position,quaternion,scale);boundingBox.expandByPoint(position)});return boundingBox};THREEx.ArMultiMarkerControls.prototype.updateSmoothedControls=function(smoothedControls,lerpsValues){if(lerpsValues===undefined){lerpsValues=[[.1,.1,.3],[.2,.1,.4],[.2,.2,.5],[.3,.2,.7],[.3,.2,.7]]}var nVisible=0;this.parameters.subMarkersControls.forEach(function(markerControls,markerIndex){var markerObject3d=markerControls.object3d;if(markerObject3d.visible===true)nVisible++});if(lerpsValues[nVisible-1]!==undefined){var lerpValues=lerpsValues[nVisible-1]}else{var lerpValues=lerpsValues[lerpsValues.length-1]}smoothedControls.parameters.lerpPosition=lerpValues[0];smoothedControls.parameters.lerpQuaternion=lerpValues[1];smoothedControls.parameters.lerpScale=lerpValues[2]};THREEx.ArMultiMarkerControls.fromJSON=function(arToolkitContext,parent3D,markerRoot,jsonData,parameters){var multiMarkerFile=JSON.parse(jsonData);var subMarkersControls=[];var subMarkerPoses=[];parameters=parameters||{};multiMarkerFile.subMarkersControls.forEach(function(item){var markerRoot=new THREE.Object3D;parent3D.add(markerRoot);var subMarkerControls=new THREEx.ArMarkerControls(arToolkitContext,markerRoot,item.parameters);subMarkersControls.push(subMarkerControls);subMarkerPoses.push((new THREE.Matrix4).fromArray(item.poseMatrix))});parameters.subMarkersControls=subMarkersControls;parameters.subMarkerPoses=subMarkerPoses;var multiMarkerControls=new THREEx.ArMultiMarkerControls(arToolkitContext,markerRoot,parameters);return multiMarkerControls};var THREEx=THREEx||{};THREEx.ArMultiMakersLearning=function(arToolkitContext,subMarkersControls){var _this=this;this._arToolkitContext=arToolkitContext;this.subMarkersControls=subMarkersControls;this.enabled=true;arToolkitContext.addEventListener("sourceProcessed",function(){_this._onSourceProcessed()})};THREEx.ArMultiMakersLearning.prototype._onSourceProcessed=function(){var originQuaternion=this.subMarkersControls[0].object3d.quaternion;if(this.enabled===false)return;var visibleMarkerControls=this.subMarkersControls.filter(function(markerControls){return markerControls.object3d.visible===true});var count=Object.keys(visibleMarkerControls).length;var positionDelta=new THREE.Vector3;var quaternionDelta=new THREE.Quaternion;var scaleDelta=new THREE.Vector3;var tmpMatrix=new THREE.Matrix4;for(var i=0;i=1?true:false;if(isLearned===true)return;var otherSubControlsID=_this._getLearnedCoupleStats(subMarkerControls);if(otherSubControlsID===null){return}var otherSubControls=_this._getSubMarkerControlsByID(otherSubControlsID);var seenCoupleStats=subMarkerControls.object3d.userData.seenCouples[otherSubControlsID];var averageMatrix=new THREE.Matrix4;averageMatrix.compose(seenCoupleStats.position.average,seenCoupleStats.quaternion.average,seenCoupleStats.scale.average);var otherAverageMatrix=otherSubControls.object3d.userData.result.averageMatrix;var matrix=(new THREE.Matrix4).getInverse(otherAverageMatrix).multiply(averageMatrix);matrix=(new THREE.Matrix4).getInverse(matrix);console.assert(subMarkerControls.object3d.userData.result===undefined);subMarkerControls.object3d.userData.result={averageMatrix:matrix,confidenceFactor:1};resultChanged=true})}while(resultChanged===true)};THREEx.ArMultiMakersLearning.prototype._getLearnedCoupleStats=function(subMarkerControls){if(subMarkerControls.object3d.userData.seenCouples===undefined)return null;var seenCouples=subMarkerControls.object3d.userData.seenCouples;var coupleControlsIDs=Object.keys(seenCouples).map(Number);for(var i=0;i=1?true:false;if(isLearned===false)continue;return otherSubControlsID}return null};THREEx.ArMultiMakersLearning.prototype._getSubMarkerControlsByID=function(controlsID){for(var i=0;i - + + @@ -37,8 +38,8 @@
- AR.js - switching between backend - by @jerome_etienne + AR.js - Session API demo with multi tracking and hit testing + - by @jerome_etienne
Marker image hiro for artoolkit @@ -65,7 +66,7 @@ Learn-new-marker-area Reset-marker-area
diff --git a/three.js/src/newAPI/arjs-anchor.js b/three.js/src/newAPI/arjs-anchor.js index a403a4b..f4ecc77 100644 --- a/three.js/src/newAPI/arjs-anchor.js +++ b/three.js/src/newAPI/arjs-anchor.js @@ -18,11 +18,14 @@ ARjs.Anchor = function(arSession, markerParameters){ this.parameters = markerParameters - console.log('ARjs.Anchor -', 'changeMatrixMode:', this.parameters.changeMatrixMode, 'markersAreaEnabled:', markerParameters.markersAreaEnabled) + // log to debug + console.log('ARjs.Anchor -', 'changeMatrixMode:', this.parameters.changeMatrixMode, '/ markersAreaEnabled:', markerParameters.markersAreaEnabled) + var markerRoot = new THREE.Group scene.add(markerRoot) + // set controlledObject depending on changeMatrixMode if( markerParameters.changeMatrixMode === 'modelViewMatrix' ){ var controlledObject = markerRoot }else if( markerParameters.changeMatrixMode === 'cameraTransformMatrix' ){ @@ -32,7 +35,7 @@ ARjs.Anchor = function(arSession, markerParameters){ if( markerParameters.markersAreaEnabled === false ){ var markerControls = new THREEx.ArMarkerControls(arContext, controlledObject, markerParameters) }else{ - // sanity check + // sanity check - MUST be a trackingBackend with markers console.assert( arContext.parameters.trackingBackend === 'artoolkit' || arContext.parameters.trackingBackend === 'aruco' ) // for multi marker if( localStorage.getItem('ARjsMultiMarkerFile') === null ){ @@ -44,7 +47,10 @@ ARjs.Anchor = function(arSession, markerParameters){ var multiMarkerFile = localStorage.getItem('ARjsMultiMarkerFile') // build a multiMarkerControls - var multiMarkerControls = THREEx.ArMultiMarkerControls.fromJSON(arContext, scene, markerRoot, multiMarkerFile) + var multiMarkerControls = THREEx.ArMultiMarkerControls.fromJSON(arContext, scene, controlledObject, multiMarkerFile) + + // honor markerParameters.changeMatrixMode + multiMarkerControls.parameters.changeMatrixMode = markerParameters.changeMatrixMode // create ArMarkerHelper - useful to debug var markerHelpers = [] @@ -56,6 +62,7 @@ ARjs.Anchor = function(arSession, markerParameters){ // add it to markerHelpers markerHelpers.push(markerHelper) }) + // define API specific to markersArea this.markersArea = {} this.markersArea.setSubMarkersVisibility = function(visible){ markerHelpers.forEach(function(markerHelper){ diff --git a/three.js/src/newAPI/arjs-hittester.js b/three.js/src/newAPI/arjs-hittester.js index 619283a..fd949a5 100644 --- a/three.js/src/newAPI/arjs-hittester.js +++ b/three.js/src/newAPI/arjs-hittester.js @@ -9,16 +9,19 @@ var ARjs = ARjs || {} */ ARjs.HitTester = function(arSession){ var _this = this + var arContext = arSession.arContext + var trackingBackend = arContext.parameters.trackingBackend + this.arSession = arSession + this._hitTesterPlane = null + this._hitTesterTango = null - var arContext = this.arSession.arContext - var trackingBackend = arContext.parameters.trackingBackend if( trackingBackend === 'tango' ){ - // Do nothing... + _this._hitTesterTango = new THREEx.HitTesterTango() }else{ arContext.addEventListener('initialized', function(event){ - _this._arClickability = new THREEx.ARClickability(arSession.arSource.domElement) + _this._hitTesterPlane = new THREEx.HitTesterPlane(arSession.arSource.domElement) _this._pickingScene = new THREE.Scene var geometry = new THREE.PlaneGeometry(20,20,19,19).rotateX(-Math.PI/2) @@ -33,24 +36,33 @@ ARjs.HitTester = function(arSession){ _this._pickingScene.add(_this._pickingPlane) }) } - - } - +////////////////////////////////////////////////////////////////////////////// +// update function +////////////////////////////////////////////////////////////////////////////// +/** + * update + * + * @param {THREE.Camera} camera - the camera to use + * @param {THREE.Object3D} object3d - + */ ARjs.HitTester.prototype.update = function (camera, object3d) { var arContext = this.arSession.arContext var trackingBackend = arContext.parameters.trackingBackend - if( trackingBackend === 'tango' ){ - // Do nothing... - }else{ + if( this._hitTesterTango !== null ){ + this._hitTesterTango.update() + }else if( this._hitTesterPlane !== null ){ + + // TODO put that in a .update + if( arContext.initialized === false ) return - this._arClickability.onResize() + this._hitTesterPlane.onResize() // // set cameraPicking position - var cameraPicking = this._arClickability._cameraPicking + var cameraPicking = this._hitTesterPlane._cameraPicking // camera.updateMatrixWorld() // cameraPicking.matrix.copy(object3d.matrixWorld) // cameraPicking.matrix.decompose(cameraPicking.position, cameraPicking.quaternion, cameraPicking.scale) @@ -70,8 +82,12 @@ ARjs.HitTester.prototype.update = function (camera, object3d) { } } +////////////////////////////////////////////////////////////////////////////// +// actual hit testing +////////////////////////////////////////////////////////////////////////////// + /** - * Test the real world for intersections. + * Test the real world for intersections directly from a DomEvent * * @param {Number} mouseX - position X of the hit [-1, +1] * @param {Number} mouseY - position Y of the hit [-1, +1] @@ -120,7 +136,7 @@ ARjs.HitTester.prototype.test = function(mouseX, mouseY){ // compute intersections between mouseVector3 and pickingPlane var raycaster = new THREE.Raycaster(); var mouseVector3 = new THREE.Vector3(mouseX, mouseY, 1); - raycaster.setFromCamera( mouseVector3, this._arClickability._cameraPicking ); + raycaster.setFromCamera( mouseVector3, this._hitTesterPlane._cameraPicking ); var intersects = raycaster.intersectObjects( [this._pickingPlane] ) // if no intersection occurs, return now @@ -141,7 +157,6 @@ ARjs.HitTester.prototype.test = function(mouseX, mouseY){ return hitTestResults } - ////////////////////////////////////////////////////////////////////////////// // ARjs.HitTester.Result ////////////////////////////////////////////////////////////////////////////// diff --git a/three.js/threex-hittester-plane.js b/three.js/threex-hittester-plane.js new file mode 100644 index 0000000..8ba55b7 --- /dev/null +++ b/three.js/threex-hittester-plane.js @@ -0,0 +1,51 @@ +var THREEx = THREEx || {} + +// TODO this is useless - prefere arjs-hittester.js + +/** + * - maybe support .onClickFcts in each object3d + * - seems an easy light layer for clickable object + * - up to + */ +THREEx.HitTesterPlane = function(sourceElement){ + this._sourceElement = sourceElement + // Create cameraPicking + var fullWidth = parseInt(sourceElement.style.width) + var fullHeight = parseInt(sourceElement.style.height) + // TODO hardcoded fov - couch + this._cameraPicking = new THREE.PerspectiveCamera(42, fullWidth / fullHeight, 0.1, 100); + +console.warn('THREEx.HitTesterPlane works only in modelViewMatrix') +// TODO just push camera in computeIntersects +} + +THREEx.HitTesterPlane.prototype.onResize = function(){ + var sourceElement = this._sourceElement + var cameraPicking = this._cameraPicking + + var fullWidth = parseInt(sourceElement.style.width) + var fullHeight = parseInt(sourceElement.style.height) + cameraPicking.aspect = fullWidth / fullHeight; + cameraPicking.updateProjectionMatrix(); +} + +THREEx.HitTesterPlane.prototype.computeIntersects = function(domEvent, objects){ + var sourceElement = this._sourceElement + var cameraPicking = this._cameraPicking + + // compute mouse coordinatge with [-1,1] + var eventCoords = new THREE.Vector3(); + eventCoords.x = ( domEvent.layerX / parseInt(sourceElement.style.width) ) * 2 - 1; + eventCoords.y = - ( domEvent.layerY / parseInt(sourceElement.style.height) ) * 2 + 1; + + // compute intersections between eventCoords and pickingPlane + var raycaster = new THREE.Raycaster(); + raycaster.setFromCamera( eventCoords, cameraPicking ); + var intersects = raycaster.intersectObjects( objects ) + + return intersects +} + +THREEx.HitTesterPlane.prototype.update = function(){ + +} diff --git a/three.js/threex-hittester-tango.js b/three.js/threex-hittester-tango.js new file mode 100644 index 0000000..9b7f9c7 --- /dev/null +++ b/three.js/threex-hittester-tango.js @@ -0,0 +1,33 @@ +var THREEx = THREEx || {} + +THREEx.HitTesterTango = function(){ +} + +THREEx.HitTesterTango.tangoPickingPointCloud = function(artoolkitContext, mouseX, mouseY){ + var vrDisplay = artoolkitContext._tangoContext.vrDisplay + if (vrDisplay === null ) return null + var pointAndPlane = vrDisplay.getPickingPointAndPlaneInPointCloud(mouseX, mouseY) + if( pointAndPlane == null ) { + console.warn('Could not retrieve the correct point and plane.') + return null + } + + // FIXME not sure what this is + var boundingSphereRadius = 0.01 + + // the bigger the number the likeliest it crash chromium-webar + + // Orient and position the model in the picking point according + // to the picking plane. The offset is half of the model size. + var object3d = new THREE.Object3D + THREE.WebAR.positionAndRotateObject3DWithPickingPointAndPlaneInPointCloud( + pointAndPlane, object3d, boundingSphereRadius + ) + object3d.rotateZ(-Math.PI/2) + + // return the result + var result = {} + result.position = object3d.position + result.quaternion = object3d.quaternion + return result +} diff --git a/webvr-polyfill/build/artoolkit-webvr-polyfill.js b/webvr-polyfill/build/artoolkit-webvr-polyfill.js index 22c7c0b..77aaa81 100644 --- a/webvr-polyfill/build/artoolkit-webvr-polyfill.js +++ b/webvr-polyfill/build/artoolkit-webvr-polyfill.js @@ -2389,9 +2389,10 @@ THREEx.ArSmoothedControls.prototype.update = function(targetObject3d){ object3d.scale.lerp(targetObject3d.scale, parameters.lerpScale) } } +var ARjs = ARjs || {} var THREEx = THREEx || {} -THREEx.ArToolkitContext = function(parameters){ +ARjs.Context = THREEx.ArToolkitContext = function(parameters){ var _this = this _this._updatedAt = null @@ -2408,7 +2409,7 @@ THREEx.ArToolkitContext = function(parameters){ matrixCodeType: '3x3', // url of the camera parameters - cameraParametersUrl: THREEx.ArToolkitContext.baseURL + 'parameters/camera_para.dat', + cameraParametersUrl: ARjs.Context.baseURL + 'parameters/camera_para.dat', // tune the maximum rate of pose detection in the source image maxDetectionRate: 60, @@ -2458,12 +2459,12 @@ THREEx.ArToolkitContext = function(parameters){ } } -Object.assign( THREEx.ArToolkitContext.prototype, THREE.EventDispatcher.prototype ); +Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype ); -// THREEx.ArToolkitContext.baseURL = '../' +// ARjs.Context.baseURL = '../' // default to github page -THREEx.ArToolkitContext.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/' -THREEx.ArToolkitContext.REVISION = '1.0.1-dev' +ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/' +ARjs.Context.REVISION = '1.0.1-dev' @@ -2472,7 +2473,7 @@ THREEx.ArToolkitContext.REVISION = '1.0.1-dev' * @param {string} trackingBackend - the tracking to user * @return {THREE.Camera} the created camera */ -THREEx.ArToolkitContext.createDefaultCamera = function( trackingBackend ){ +ARjs.Context.createDefaultCamera = function( trackingBackend ){ console.assert(false, 'use ARjs.Utils.createDefaultCamera instead') // Create a camera if( trackingBackend === 'artoolkit' ){ @@ -2489,7 +2490,7 @@ THREEx.ArToolkitContext.createDefaultCamera = function( trackingBackend ){ ////////////////////////////////////////////////////////////////////////////// // init functions ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype.init = function(onCompleted){ +ARjs.Context.prototype.init = function(onCompleted){ var _this = this if( this.parameters.trackingBackend === 'artoolkit' ){ this._initArtoolkit(done) @@ -2515,7 +2516,7 @@ THREEx.ArToolkitContext.prototype.init = function(onCompleted){ //////////////////////////////////////////////////////////////////////////////// // update function //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype.update = function(srcElement){ +ARjs.Context.prototype.update = function(srcElement){ // be sure arController is fully initialized if(this.parameters.trackingBackend === 'artoolkit' && this.arController === null) return false; @@ -2556,12 +2557,12 @@ THREEx.ArToolkitContext.prototype.update = function(srcElement){ //////////////////////////////////////////////////////////////////////////////// // Add/Remove markerControls //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype.addMarker = function(arMarkerControls){ +ARjs.Context.prototype.addMarker = function(arMarkerControls){ console.assert(arMarkerControls instanceof THREEx.ArMarkerControls) this._arMarkersControls.push(arMarkerControls) } -THREEx.ArToolkitContext.prototype.removeMarker = function(arMarkerControls){ +ARjs.Context.prototype.removeMarker = function(arMarkerControls){ console.assert(arMarkerControls instanceof THREEx.ArMarkerControls) // console.log('remove marker for', arMarkerControls) var index = this.arMarkerControlss.indexOf(artoolkitMarker); @@ -2572,7 +2573,7 @@ THREEx.ArToolkitContext.prototype.removeMarker = function(arMarkerControls){ ////////////////////////////////////////////////////////////////////////////// // artoolkit specific ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype._initArtoolkit = function(onCompleted){ +ARjs.Context.prototype._initArtoolkit = function(onCompleted){ var _this = this // set this._artoolkitProjectionAxisTransformMatrix to change artoolkit projection matrix axis to match usual webgl one @@ -2643,7 +2644,7 @@ THREEx.ArToolkitContext.prototype._initArtoolkit = function(onCompleted){ /** * return the projection matrix */ -THREEx.ArToolkitContext.prototype.getProjectionMatrix = function(srcElement){ +ARjs.Context.prototype.getProjectionMatrix = function(srcElement){ // FIXME rename this function to say it is artoolkit specific - getArtoolkitProjectMatrix @@ -2666,14 +2667,14 @@ THREEx.ArToolkitContext.prototype.getProjectionMatrix = function(srcElement){ return projectionMatrix } -THREEx.ArToolkitContext.prototype._updateArtoolkit = function(srcElement){ +ARjs.Context.prototype._updateArtoolkit = function(srcElement){ this.arController.process(srcElement) } ////////////////////////////////////////////////////////////////////////////// // aruco specific ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype._initAruco = function(onCompleted){ +ARjs.Context.prototype._initAruco = function(onCompleted){ this.arucoContext = new THREEx.ArucoContext() // honor this.parameters.canvasWidth/.canvasHeight @@ -2694,7 +2695,7 @@ THREEx.ArToolkitContext.prototype._initAruco = function(onCompleted){ } -THREEx.ArToolkitContext.prototype._updateAruco = function(srcElement){ +ARjs.Context.prototype._updateAruco = function(srcElement){ // console.log('update aruco here') var _this = this var arMarkersControls = this._arMarkersControls @@ -2722,7 +2723,7 @@ THREEx.ArToolkitContext.prototype._updateAruco = function(srcElement){ ////////////////////////////////////////////////////////////////////////////// // tango specific ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitContext.prototype._initTango = function(onCompleted){ +ARjs.Context.prototype._initTango = function(onCompleted){ var _this = this // check webvr is available if (navigator.getVRDisplays){ @@ -2765,7 +2766,7 @@ THREEx.ArToolkitContext.prototype._initTango = function(onCompleted){ } -THREEx.ArToolkitContext.prototype._updateTango = function(srcElement){ +ARjs.Context.prototype._updateTango = function(srcElement){ // console.log('update aruco here') var _this = this var arMarkersControls = this._arMarkersControls @@ -2818,7 +2819,6 @@ THREEx.ArToolkitContext.prototype._updateTango = function(srcElement){ } var ARjs = ARjs || {} - var THREEx = THREEx || {} /** @@ -2994,32 +2994,59 @@ ARjs.Profile.prototype.checkIfValid = function () { } return this } +var ARjs = ARjs || {} var THREEx = THREEx || {} -THREEx.ArToolkitSource = function(parameters){ +ARjs.Source = THREEx.ArToolkitSource = function(parameters){ + var _this = this + + this.ready = false + this.domElement = null + // handle default parameters this.parameters = { // type of source - ['webcam', 'image', 'video'] - sourceType : parameters.sourceType !== undefined ? parameters.sourceType : 'webcam', + sourceType : 'webcam', // url of the source - valid if sourceType = image|video - sourceUrl : parameters.sourceUrl !== undefined ? parameters.sourceUrl : null, + sourceUrl : null, // resolution of at which we initialize in the source image - sourceWidth: parameters.sourceWidth !== undefined ? parameters.sourceWidth : 640, - sourceHeight: parameters.sourceHeight !== undefined ? parameters.sourceHeight : 480, + sourceWidth: 640, + sourceHeight: 480, // resolution displayed for the source - displayWidth: parameters.displayWidth !== undefined ? parameters.displayWidth : 640, - displayHeight: parameters.displayHeight !== undefined ? parameters.displayHeight : 480, + displayWidth: 640, + displayHeight: 480, } + ////////////////////////////////////////////////////////////////////////////// + // setParameters + ////////////////////////////////////////////////////////////////////////////// + setParameters(parameters) + function setParameters(parameters){ + if( parameters === undefined ) return + for( var key in parameters ){ + var newValue = parameters[ key ] - this.ready = false - this.domElement = null + if( newValue === undefined ){ + console.warn( "THREEx.ArToolkitSource: '" + key + "' parameter is undefined." ) + continue + } + + var currentValue = _this.parameters[ key ] + + if( currentValue === undefined ){ + console.warn( "THREEx.ArToolkitSource: '" + key + "' is not a property of this material." ) + continue + } + + _this.parameters[ key ] = newValue + } + } } ////////////////////////////////////////////////////////////////////////////// // Code Separator ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.init = function(onReady, onError){ +ARjs.Source.prototype.init = function(onReady, onError){ var _this = this if( this.parameters.sourceType === 'image' ){ @@ -3055,7 +3082,7 @@ THREEx.ArToolkitSource.prototype.init = function(onReady, onError){ //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype._initSourceImage = function(onReady) { +ARjs.Source.prototype._initSourceImage = function(onReady) { // TODO make it static var domElement = document.createElement('img') domElement.src = this.parameters.sourceUrl @@ -3080,7 +3107,7 @@ THREEx.ArToolkitSource.prototype._initSourceImage = function(onReady) { //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype._initSourceVideo = function(onReady) { +ARjs.Source.prototype._initSourceVideo = function(onReady) { // TODO make it static var domElement = document.createElement('video'); domElement.src = this.parameters.sourceUrl @@ -3117,12 +3144,12 @@ THREEx.ArToolkitSource.prototype._initSourceVideo = function(onReady) { // handle webcam source //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype._initSourceWebcam = function(onReady, onError) { +ARjs.Source.prototype._initSourceWebcam = function(onReady, onError) { var _this = this -debugger + // init default value onError = onError || function(error){ - alert('Cant init webcam due to '+error.message) + alert('Webcam Error\nName: '+error.name + '\nMessage: '+error.message) } var domElement = document.createElement('video'); @@ -3132,13 +3159,18 @@ debugger domElement.style.width = this.parameters.displayWidth+'px' domElement.style.height = this.parameters.displayHeight+'px' + // check API is available if (navigator.mediaDevices === undefined || navigator.mediaDevices.enumerateDevices === undefined || navigator.mediaDevices.getUserMedia === undefined ){ - onError("WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser") + onError({ + name: '', + message: 'WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser' + }) return } + // get available devices navigator.mediaDevices.enumerateDevices().then(function(devices) { var userMediaConstraints = { audio: false, @@ -3156,6 +3188,7 @@ debugger } } } + // get a device which satisfy the constraints navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream) { // set the .src of the domElement domElement.srcObject = stream; @@ -3164,6 +3197,7 @@ debugger domElement.play(); }) // domElement.play(); + // TODO listen to loadedmetadata instead // wait until the video stream is ready var interval = setInterval(function() { @@ -3173,7 +3207,8 @@ debugger }, 1000/50); }).catch(function(error) { onError({ - message: "Can't access user media :()" + name: error.name, + message: error.message }); }); }).catch(function(error) { @@ -3188,7 +3223,7 @@ debugger ////////////////////////////////////////////////////////////////////////////// // Handle Mobile Torch ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.hasMobileTorch = function(){ +ARjs.Source.prototype.hasMobileTorch = function(){ var stream = arToolkitSource.domElement.srcObject if( stream instanceof MediaStream === false ) return false @@ -3210,7 +3245,7 @@ THREEx.ArToolkitSource.prototype.hasMobileTorch = function(){ * toggle the flash/torch of the mobile fun if applicable. * Great post about it https://www.oberhofer.co/mediastreamtrack-and-its-capabilities/ */ -THREEx.ArToolkitSource.prototype.toggleMobileTorch = function(){ +ARjs.Source.prototype.toggleMobileTorch = function(){ // sanity check console.assert(this.hasMobileTorch() === true) @@ -3246,7 +3281,7 @@ THREEx.ArToolkitSource.prototype.toggleMobileTorch = function(){ // handle resize //////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.onResizeElement = function(mirrorDomElements){ +ARjs.Source.prototype.onResizeElement = function(mirrorDomElements){ var _this = this var screenWidth = window.innerWidth var screenHeight = window.innerHeight @@ -3304,7 +3339,7 @@ THREEx.ArToolkitSource.prototype.onResizeElement = function(mirrorDomElements){ }) } -THREEx.ArToolkitSource.prototype.copyElementSizeTo = function(otherElement){ +ARjs.Source.prototype.copyElementSizeTo = function(otherElement){ otherElement.style.width = this.domElement.style.width otherElement.style.height = this.domElement.style.height otherElement.style.marginLeft = this.domElement.style.marginLeft @@ -3315,7 +3350,7 @@ THREEx.ArToolkitSource.prototype.copyElementSizeTo = function(otherElement){ // Code Separator ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.copySizeTo = function(){ +ARjs.Source.prototype.copySizeTo = function(){ console.warn('obsolete function arToolkitSource.copySizeTo. Use arToolkitSource.copyElementSizeTo' ) this.copyElementSizeTo.apply(this, arguments) } @@ -3324,14 +3359,15 @@ THREEx.ArToolkitSource.prototype.copySizeTo = function(){ // Code Separator ////////////////////////////////////////////////////////////////////////////// -THREEx.ArToolkitSource.prototype.onResize = function(arToolkitContext, renderer, camera){ - var trackingBackend = arToolkitContext.parameters.trackingBackend - +ARjs.Source.prototype.onResize = function(arToolkitContext, renderer, camera){ if( arguments.length !== 3 ){ console.warn('obsolete function arToolkitSource.onResize. Use arToolkitSource.onResizeElement' ) return this.onResizeElement.apply(this, arguments) } + var trackingBackend = arToolkitContext.parameters.trackingBackend + + // RESIZE DOMELEMENT if( trackingBackend === 'artoolkit' ){ diff --git a/webvr-polyfill/build/artoolkit-webvr-polyfill.min.js b/webvr-polyfill/build/artoolkit-webvr-polyfill.min.js index 48cf891..ad31cc0 100644 --- a/webvr-polyfill/build/artoolkit-webvr-polyfill.min.js +++ b/webvr-polyfill/build/artoolkit-webvr-polyfill.min.js @@ -23,5 +23,5 @@ c[f+260>>2]=e;if((e|0)<0){c[g>>2]=d;Me(3,6312,g);Ce(c[b>>2]|0)|0;Me(3,6358,h);e= n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}else{b[e>>1]=0;a[l>>0]=0;j=r}while(0);t=t+1|0;n=s+2|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+4|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Dd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<1)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){p=d[s>>0]|0;q=d[s+1>>0]|0;do if(((p&248)+12+(p<<5&224)+(q>>>3&24)+(q<<2&248)|0)>(A|0)){a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}else{b[e>>1]=0;a[l>>0]=0;j=r}while(0);t=t+1|0;n=s+2|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+4|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Ed(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;p=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=p;n=p+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=j*3|0;z=f+-1|0;if((g|0)>0){l=0;j=p;m=p+(z<<1)|0;while(1){b[m>>1]=0;b[j>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{j=j+(f<<1)|0;m=m+(f<<1)|0}}}m=k+1179664|0;l=f+1|0;w=0-f|0;u=1-f|0;v=~f;a:do if((B|0)>1){x=(z|0)>1;o=(c[k+4>>2]|0)+l|0;y=1;n=e+(l<<2)|0;e=p+(l<<1)|0;j=0;b:while(1){if(x){l=o;t=1;s=n;r=j;while(1){do if(((d[s+2>>0]|0)+(d[s+1>>0]|0)+(d[s+3>>0]|0)|0)>(A|0)){a[l>>0]=-1;j=b[e+(w<<1)>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}o=b[e+(u<<1)>>1]|0;p=o<<16>>16;j=b[e+(v<<1)>>1]|0;q=j<<16>>16;n=j<<16>>16>0;if(o<<16>>16<=0){if(n){b[e>>1]=j;j=q*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-3<<2)|0;if((c[n>>2]|0)<(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=b[e+-2>>1]|0;if(j<<16>>16>0){b[e>>1]=j;j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;j=k+1310736+(j+-3<<2)|0;if((c[j>>2]|0)>=(t|0)){j=r;break}c[j>>2]=t;j=r;break}else{j=r+1|0;if((r|0)>32767)break b;b[e>>1]=j;c[k+1179664+(r<<2)>>2]=j<<16>>16;r=r*7|0;c[k+1310736+(r<<2)>>2]=1;c[k+1310736+(r+1<<2)>>2]=t;c[k+1310736+(r+2<<2)>>2]=y;c[k+1310736+(r+3<<2)>>2]=t;c[k+1310736+(r+4<<2)>>2]=t;c[k+1310736+(r+5<<2)>>2]=y;c[k+1310736+(r+6<<2)>>2]=y;break}}if(n){j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+(q+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;q=k+1310736+(j+-5<<2)|0;c[q>>2]=(c[q>>2]|0)+y;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}n=b[e+-2>>1]|0;if(n<<16>>16<=0){b[e>>1]=o;j=p*7|0;n=k+1310736+(j+-7<<2)|0;c[n>>2]=(c[n>>2]|0)+1;n=k+1310736+(j+-6<<2)|0;c[n>>2]=(c[n>>2]|0)+t;n=k+1310736+(j+-5<<2)|0;c[n>>2]=(c[n>>2]|0)+y;n=k+1310736+(j+-4<<2)|0;if((c[n>>2]|0)>(t|0))c[n>>2]=t;c[k+1310736+(j+-1<<2)>>2]=y;j=r;break}j=c[k+1179664+(p+-1<<2)>>2]|0;p=c[k+1179664+((n<<16>>16)+-1<<2)>>2]|0;if((j|0)>(p|0)){b[e>>1]=p;if((r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(j|0))c[o>>2]=p;n=n+1|0;if((n|0)>=(r|0)){j=p;break}else o=o+4|0}}else j=p}else{b[e>>1]=j;if((j|0)<(p|0)&(r|0)>0){n=0;o=m;while(1){if((c[o>>2]|0)==(p|0))c[o>>2]=j;n=n+1|0;if((n|0)>=(r|0))break;else o=o+4|0}}}j=(j<<16>>16)*7|0;q=k+1310736+(j+-7<<2)|0;c[q>>2]=(c[q>>2]|0)+1;q=k+1310736+(j+-6<<2)|0;c[q>>2]=(c[q>>2]|0)+t;j=k+1310736+(j+-5<<2)|0;c[j>>2]=(c[j>>2]|0)+y;j=r}else{b[e>>1]=0;a[l>>0]=0;j=r}while(0);t=t+1|0;n=s+4|0;e=e+2|0;l=l+1|0;if((t|0)>=(z|0))break;else{s=n;r=j}}}else l=o;y=y+1|0;if((y|0)>=(B|0)){p=j;D=52;break a}else{o=l+2|0;n=n+8|0;e=e+4|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){e=k+12|0;if((p|0)<1)j=1;else{n=1;j=1;while(1){l=c[m>>2]|0;if((l|0)==(n|0)){l=j;j=j+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[m>>2]=l;if((n|0)<(p|0)){n=n+1|0;m=m+4|0}else break}}o=k+8|0;l=j+-1|0;c[o>>2]=l;if(l){ek(e|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((j|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[o>>2]|0))}if((p|0)>0){e=0;do{m=(c[k+1179664+(e<<2)>>2]|0)+-1|0;n=e*7|0;l=k+12+(m<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(n<<2)>>2]|0);l=m<<1;j=k+655376+(l<<3)|0;h[j>>3]=+h[j>>3]+ +(c[k+1310736+(n+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(n+2<<2)>>2]|0);m=m<<2;l=k+131084+(m<<2)|0;j=c[k+1310736+(n+3<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;l=k+131084+((m|1)<<2)|0;j=c[k+1310736+(n+4<<2)>>2]|0;if((c[l>>2]|0)<(j|0))c[l>>2]=j;l=k+131084+((m|2)<<2)|0;j=c[k+1310736+(n+5<<2)>>2]|0;if((c[l>>2]|0)>(j|0))c[l>>2]=j;j=k+131084+((m|3)<<2)|0;l=c[k+1310736+(n+6<<2)>>2]|0;if((c[j>>2]|0)<(l|0))c[j>>2]=l;e=e+1|0}while((e|0)<(p|0))}if((c[o>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[o>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Fd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;l=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;p=(c[k+4>>2]|0)+l|0;z=1;e=e+l|0;o=o+(l<<1)|0;m=0;b:while(1){if(y){l=p;u=1;t=e;s=m;while(1){do if((d[t>>0]|0|0)>(j|0)){a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}else{b[o>>1]=0;a[l>>0]=0;m=s}while(0);u=u+1|0;e=t+1|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}else l=p;z=z+1|0;if((z|0)>=(B|0)){q=m;D=52;break a}else{p=l+2|0;e=e+2|0;o=o+4|0}}Me(3,3904,C);l=-1}else{q=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((q|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(q|0)){e=e+1|0;n=n+4|0}else break}}p=k+8|0;l=m+-1|0;c[p>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[p>>2]|0))}if((q|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(q|0))}if((c[p>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[p>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Gd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;l=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;p=(c[k+4>>2]|0)+l|0;z=1;e=e+(l<<1)|0;o=o+(l<<1)|0;m=0;b:while(1){if(y){l=p;u=1;t=e;s=m;while(1){do if((d[t+1>>0]|0|0)>(j|0)){a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}else{b[o>>1]=0;a[l>>0]=0;m=s}while(0);u=u+1|0;e=t+2|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}else l=p;z=z+1|0;if((z|0)>=(B|0)){q=m;D=52;break a}else{p=l+2|0;e=e+4|0;o=o+4|0}}Me(3,3904,C);l=-1}else{q=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((q|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(q|0)){e=e+1|0;n=n+4|0}else break}}p=k+8|0;l=m+-1|0;c[p>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[p>>2]|0))}if((q|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(q|0))}if((c[p>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[p>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Hd(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;l=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;p=(c[k+4>>2]|0)+l|0;z=1;e=e+(l<<1)|0;o=o+(l<<1)|0;m=0;b:while(1){if(y){l=p;u=1;t=e;s=m;while(1){do if((d[t>>0]|0|0)>(j|0)){a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}else{b[o>>1]=0;a[l>>0]=0;m=s}while(0);u=u+1|0;e=t+2|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}else l=p;z=z+1|0;if((z|0)>=(B|0)){q=m;D=52;break a}else{p=l+2|0;e=e+4|0;o=o+4|0}}Me(3,3904,C);l=-1}else{q=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((q|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(q|0)){e=e+1|0;n=n+4|0}else break}}p=k+8|0;l=m+-1|0;c[p>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[p>>2]|0))}if((q|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(q|0))}if((c[p>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[p>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Id(e,f,g,j,k){e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0;E=i;i=i+16|0;C=E;o=c[k>>2]|0;B=g+-1|0;if((f|0)>0){l=0;m=o;n=o+(($(B,f)|0)<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(f|0))break;else{m=m+2|0;n=n+2|0}}}A=f+-1|0;if((g|0)>0){l=0;m=o;n=o+(A<<1)|0;while(1){b[n>>1]=0;b[m>>1]=0;l=l+1|0;if((l|0)>=(g|0))break;else{m=m+(f<<1)|0;n=n+(f<<1)|0}}}n=k+1179664|0;m=f+1|0;x=0-f|0;v=1-f|0;w=~f;a:do if((B|0)>1){y=(A|0)>1;l=(c[k+4>>2]|0)+m|0;z=1;e=e+m|0;o=o+(m<<1)|0;j=j+m|0;m=0;b:while(1){if(y){u=1;t=e;s=m;while(1){do if((d[t>>0]|0)>(d[j>>0]|0)){a[l>>0]=-1;m=b[o+(x<<1)>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}p=b[o+(v<<1)>>1]|0;q=p<<16>>16;m=b[o+(w<<1)>>1]|0;r=m<<16>>16;e=m<<16>>16>0;if(p<<16>>16<=0){if(e){b[o>>1]=m;m=r*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-3<<2)|0;if((c[e>>2]|0)<(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=b[o+-2>>1]|0;if(m<<16>>16>0){b[o>>1]=m;m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;m=k+1310736+(m+-3<<2)|0;if((c[m>>2]|0)>=(u|0)){m=s;break}c[m>>2]=u;m=s;break}else{m=s+1|0;if((s|0)>32767)break b;b[o>>1]=m;c[k+1179664+(s<<2)>>2]=m<<16>>16;s=s*7|0;c[k+1310736+(s<<2)>>2]=1;c[k+1310736+(s+1<<2)>>2]=u;c[k+1310736+(s+2<<2)>>2]=z;c[k+1310736+(s+3<<2)>>2]=u;c[k+1310736+(s+4<<2)>>2]=u;c[k+1310736+(s+5<<2)>>2]=z;c[k+1310736+(s+6<<2)>>2]=z;break}}if(e){m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+(r+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;r=k+1310736+(m+-5<<2)|0;c[r>>2]=(c[r>>2]|0)+z;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}e=b[o+-2>>1]|0;if(e<<16>>16<=0){b[o>>1]=p;m=q*7|0;e=k+1310736+(m+-7<<2)|0;c[e>>2]=(c[e>>2]|0)+1;e=k+1310736+(m+-6<<2)|0;c[e>>2]=(c[e>>2]|0)+u;e=k+1310736+(m+-5<<2)|0;c[e>>2]=(c[e>>2]|0)+z;e=k+1310736+(m+-4<<2)|0;if((c[e>>2]|0)>(u|0))c[e>>2]=u;c[k+1310736+(m+-1<<2)>>2]=z;m=s;break}m=c[k+1179664+(q+-1<<2)>>2]|0;q=c[k+1179664+((e<<16>>16)+-1<<2)>>2]|0;if((m|0)>(q|0)){b[o>>1]=q;if((s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(m|0))c[p>>2]=q;e=e+1|0;if((e|0)>=(s|0)){m=q;break}else p=p+4|0}}else m=q}else{b[o>>1]=m;if((m|0)<(q|0)&(s|0)>0){e=0;p=n;while(1){if((c[p>>2]|0)==(q|0))c[p>>2]=m;e=e+1|0;if((e|0)>=(s|0))break;else p=p+4|0}}}m=(m<<16>>16)*7|0;r=k+1310736+(m+-7<<2)|0;c[r>>2]=(c[r>>2]|0)+1;r=k+1310736+(m+-6<<2)|0;c[r>>2]=(c[r>>2]|0)+u;m=k+1310736+(m+-5<<2)|0;c[m>>2]=(c[m>>2]|0)+z;m=s}else{b[o>>1]=0;a[l>>0]=0;m=s}while(0);u=u+1|0;e=t+1|0;j=j+1|0;o=o+2|0;l=l+1|0;if((u|0)>=(A|0))break;else{t=e;s=m}}}z=z+1|0;if((z|0)>=(B|0)){p=m;D=52;break a}else{l=l+2|0;e=e+2|0;o=o+4|0;j=j+2|0}}Me(3,3904,C);l=-1}else{p=0;D=52}while(0);if((D|0)==52){o=k+12|0;if((p|0)<1)m=1;else{e=1;m=1;while(1){l=c[n>>2]|0;if((l|0)==(e|0)){l=m;m=m+1|0}else l=c[k+1179664+(l+-1<<2)>>2]|0;c[n>>2]=l;if((e|0)<(p|0)){e=e+1|0;n=n+4|0}else break}}j=k+8|0;l=m+-1|0;c[j>>2]=l;if(l){ek(o|0,0,l<<2|0)|0;ek(k+655376|0,0,l<<4|0)|0;if((m|0)>1){l=0;do{D=l<<2;c[k+131084+(D<<2)>>2]=f;c[k+131084+((D|1)<<2)>>2]=0;c[k+131084+((D|2)<<2)>>2]=g;c[k+131084+((D|3)<<2)>>2]=0;l=l+1|0}while((l|0)<(c[j>>2]|0))}if((p|0)>0){o=0;do{n=(c[k+1179664+(o<<2)>>2]|0)+-1|0;e=o*7|0;l=k+12+(n<<2)|0;c[l>>2]=(c[l>>2]|0)+(c[k+1310736+(e<<2)>>2]|0);l=n<<1;m=k+655376+(l<<3)|0;h[m>>3]=+h[m>>3]+ +(c[k+1310736+(e+1<<2)>>2]|0);l=k+655376+((l|1)<<3)|0;h[l>>3]=+h[l>>3]+ +(c[k+1310736+(e+2<<2)>>2]|0);n=n<<2;l=k+131084+(n<<2)|0;m=c[k+1310736+(e+3<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;l=k+131084+((n|1)<<2)|0;m=c[k+1310736+(e+4<<2)>>2]|0;if((c[l>>2]|0)<(m|0))c[l>>2]=m;l=k+131084+((n|2)<<2)|0;m=c[k+1310736+(e+5<<2)>>2]|0;if((c[l>>2]|0)>(m|0))c[l>>2]=m;m=k+131084+((n|3)<<2)|0;l=c[k+1310736+(e+6<<2)>>2]|0;if((c[m>>2]|0)<(l|0))c[m>>2]=l;o=o+1|0}while((o|0)<(p|0))}if((c[j>>2]|0)>0){l=0;do{f=k+12+(l<<2)|0;g=l<<1;D=k+655376+(g<<3)|0;h[D>>3]=+h[D>>3]/+(c[f>>2]|0);g=k+655376+((g|1)<<3)|0;h[g>>3]=+h[g>>3]/+(c[f>>2]|0);l=l+1|0}while((l|0)<(c[j>>2]|0));l=0}else l=0}else l=0}i=E;return l|0}function Jd(a){a=a|0;return Kd(a+8|0)|0}function Kd(a){a=a|0;var b=0,d=0;d=i;i=i+16|0;b=Uj(4)|0;if(!b){Me(3,5472,d);rb(1)}a=wf(a)|0;c[b>>2]=a;if(!a){Vj(b);b=0}i=d;return b|0}function Ld(a){a=a|0;var b=0;b=c[a>>2]|0;if(!b)b=-1;else{xf(b)|0;Vj(c[a>>2]|0);c[a>>2]=0;b=0}return b|0}function Md(a){a=a|0;var b=0,d=0,e=0;d=i;i=i+16|0;b=Uj(7062432)|0;if(!b){Me(3,5472,d);rb(1)}c[b>>2]=0;c[b+4834148>>2]=0;c[b+7062408>>2]=0;c[b+4>>2]=-1;c[b+8>>2]=0;c[b+12>>2]=1;c[b+16>>2]=100;c[b+20>>2]=0;c[b+24>>2]=0;c[b+28>>2]=2;h[b+7062416>>3]=.5;c[b+7062424>>2]=3;c[b+32>>2]=a;e=c[a>>2]|0;c[b+36>>2]=e;a=c[a+4>>2]|0;c[b+40>>2]=a;c[b+44>>2]=0;c[b+15408>>2]=0;c[b+4834152>>2]=0;c[b+4818296>>2]=0;a=Uj($(e<<1,a)|0)|0;c[b+4834144>>2]=a;if(!a){Me(3,5472,d+8|0);rb(1)}else{c[b+7062384>>2]=0;Nd(b,2)|0;Od(b,0)|0;c[b+7062388>>2]=-1;Pd(b,0)|0;c[b+7062392>>2]=7;c[b+7062396>>2]=0;i=d;return b|0}return 0}function Nd(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;g=i;i=i+16|0;d=g;a:do if(a){e=a+4|0;if((c[e>>2]|0)!=(b|0)){switch(b|0){case 11:case 10:case 9:case 8:case 7:case 6:case 4:case 3:case 2:case 1:case 0:{f=0;break}case 14:case 13:case 12:case 5:{f=1;break}default:{c[d>>2]=b;Me(3,3936,d);d=-1;break a}}c[e>>2]=b;c[a+8>>2]=Pe(b)|0;d=a+7062408|0;b=c[d>>2]|0;if(b){pe(b);c[d>>2]=oe(c[a+36>>2]|0,c[a+40>>2]|0,c[e>>2]|0,0)|0}d=a+24|0;b=c[d>>2]|0;if(!f)switch(b|0){case 1:{c[d>>2]=4;d=0;break a}case 4:{c[d>>2]=3;d=0;break a}default:{d=0;break a}}else switch(b|0){case 0:{c[d>>2]=1;d=0;break a}case 3:{c[d>>2]=4;d=0;break a}default:{d=0;break a}}}else d=0; }else d=-1;while(0);i=g;return d|0}function Od(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;f=i;i=i+16|0;e=f;do if(a)if((c[a>>2]|0)!=(b|0)){c[a>>2]=b;if(!b){d=a+4834148|0;Vj(c[d>>2]|0);c[d>>2]=0;d=0;break}b=Uj($(c[a+40>>2]|0,c[a+36>>2]|0)|0)|0;c[a+4834148>>2]=b;if(!b){Me(3,5472,e);rb(1)}else d=0}else d=0;else d=-1;while(0);i=f;return d|0}function Pd(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0;j=i;i=i+16|0;h=j+8|0;f=j;if(a){g=a+7062388|0;if((c[g>>2]|0)!=(b|0)){d=a+7062408|0;e=c[d>>2]|0;if(e){pe(e);c[d>>2]=0}switch(b|0){case 3:case 2:case 1:{c[d>>2]=oe(c[a+36>>2]|0,c[a+40>>2]|0,c[a+4>>2]|0,0)|0;break}case 4:{c[a+7062404>>2]=1;c[a+7062400>>2]=1;b=4;break}case 0:{b=0;break}default:{Me(3,3985,f);b=0}}c[g>>2]=b;if((c[a>>2]|0)==1){c[h>>2]=c[760+(b<<2)>>2];Me(3,4059,h);b=0}else b=0}else b=0}else b=-1;i=j;return b|0}function Qd(a){a=a|0;var b=0,d=0;if(!a)b=-1;else{b=a+7062408|0;d=c[b>>2]|0;if(d){pe(d);c[b>>2]=0}Vj(c[a+4834144>>2]|0);Vj(c[a+4834148>>2]|0);Vj(a);b=0}return b|0}function Rd(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a>>2];a=0}else a=-1;return a|0}function Sd(a,b){a=a|0;b=b|0;if((a|0)!=0&b>>>0<2){c[a+12>>2]=b;a=0}else a=-1;return a|0}function Td(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a+12>>2];a=0}else a=-1;return a|0}function Ud(a,b){a=a|0;b=b|0;if((a|0)==0|b>>>0>255)a=-1;else{c[a+16>>2]=b;a=0}return a|0}function Vd(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a+16>>2];a=0}else a=-1;return a|0}function Wd(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a+7062388>>2];a=0}else a=-1;return a|0}function Xd(a,b){a=a|0;b=b|0;if((a|0)!=0&b>>>0<2){c[a+20>>2]=b;a=0}else a=-1;return a|0}function Yd(a,b){a=a|0;b=b|0;if(!a)a=-1;else{c[b>>2]=c[a+20>>2];a=0}return a|0}function Zd(a,b){a=a|0;b=b|0;if((a|0)!=0&b>>>0<5){c[a+24>>2]=b;a=0}else a=-1;return a|0}function _d(a,b){a=a|0;b=b|0;if(!a)a=-1;else{c[a+7062424>>2]=b;a=0}return a|0}function $d(a,b){a=a|0;b=b|0;if((a|0)!=0&(b|0)!=0){c[b>>2]=c[a+7062424>>2];a=0}else a=-1;return a|0}function ae(a,b){a=a|0;b=b|0;if(!a)a=-1;else{c[b>>2]=c[a+24>>2];a=0}return a|0}function be(a,b){a=a|0;b=+b;if((a|0)!=0?!(b<=0.0|b>=1.0):0){h[a+7062416>>3]=b;a=0}else a=-1;return a|0}function ce(a,b){a=a|0;b=b|0;if(!a)a=-1;else{h[b>>3]=+h[a+7062416>>3];a=0}return a|0}function de(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,j=0.0,k=0,l=0,m=0,n=0.0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0.0,P=0,Q=0,R=0.0,S=0.0;Q=i;i=i+80|0;M=Q+32|0;G=Q+24|0;z=Q;y=Q+52|0;D=Q+40|0;L=Q+64|0;P=a+44|0;c[P>>2]=0;J=a+7062388|0;f=c[J>>2]|0;a:do if((f|0)==4){I=a+7062396|0;e=c[I>>2]|0;do if((e|0)>0){f=4;e=e+-1|0}else{C=a+16|0;F=c[C>>2]|0;E=a+7062400|0;A=(c[E>>2]|0)+F|0;A=(A|0)>255?255:A;c[y>>2]=A;H=a+7062404|0;B=F-(c[H>>2]|0)|0;B=(B|0)<0?0:B;c[y+4>>2]=B;c[y+8>>2]=F;e=a+36|0;f=a+40|0;g=a+4|0;k=a+12|0;l=a+20|0;m=a+4834144|0;p=a+15416|0;q=a+15408|0;r=a+7062384|0;s=a+24|0;t=a+32|0;u=a+7062416|0;v=a+48|0;w=a+7062424|0;x=0;do{if((xe(b,c[e>>2]|0,c[f>>2]|0,c[g>>2]|0,c[a>>2]|0,c[k>>2]|0,c[y+(x<<2)>>2]|0,c[l>>2]|0,m,0)|0)<0){e=-1;break a}if((fe(c[e>>2]|0,c[f>>2]|0,m,c[l>>2]|0,1e6,70,1.0,p,q)|0)<0){e=-1;break a}if((je(b,c[e>>2]|0,c[f>>2]|0,c[g>>2]|0,p,c[q>>2]|0,c[r>>2]|0,c[l>>2]|0,c[s>>2]|0,(c[t>>2]|0)+184|0,+h[u>>3],v,P,c[w>>2]|0)|0)<0){e=-1;break a}c[D+(x<<2)>>2]=c[P>>2];x=x+1|0}while((x|0)<3);if((c[a>>2]|0)==1){N=c[D+4>>2]|0;g=c[D+8>>2]|0;f=c[D>>2]|0;c[z>>2]=B;c[z+4>>2]=N;c[z+8>>2]=F;c[z+12>>2]=g;c[z+16>>2]=A;c[z+20>>2]=f;Me(3,4153,z)}else{f=c[D>>2]|0;g=c[D+8>>2]|0}e=c[D+4>>2]|0;if((f|0)>(g|0)|(e|0)>(g|0)){f=(f|0)>=(e|0)?A:B;c[C>>2]=f;e=f-F|0;if((e|0)>0){c[E>>2]=e;e=1}else{c[E>>2]=1;e=0-e|0}c[H>>2]=e;if((c[a>>2]|0)==1){c[G>>2]=f;Me(3,4229,G)}f=c[J>>2]|0;e=c[a+7062392>>2]|0;break}e=c[E>>2]|0;f=c[H>>2]|0;do if((e|0)>=(f|0))if((e|0)>(f|0)){c[H>>2]=f+1;break}else{e=e+1|0;c[E>>2]=e;c[H>>2]=f+1;break}else{e=e+1|0;c[E>>2]=e}while(0);if((e+F|0)>254){c[E>>2]=1;e=1}if((F|0)<=(e|0))c[H>>2]=1;c[I>>2]=c[a+7062392>>2];N=47;break a}while(0);c[I>>2]=e;N=30}else N=30;while(0);b:do if((N|0)==30){c:do switch(f|0){case 3:{f=a+7062408|0;e=we(c[f>>2]|0,b,9,-7)|0;if((e|0)<0)break b;e=c[f>>2]|0;f=a+4834144|0;e=xe(c[e>>2]|0,c[e+8>>2]|0,c[e+12>>2]|0,5,c[a>>2]|0,c[a+12>>2]|0,0,0,f,c[e+4>>2]|0)|0;if((e|0)<0)break b;e=a+36|0;g=a+40|0;k=a+20|0;break}case 2:case 1:{g=a+7062396|0;e=c[g>>2]|0;if((e|0)>0){c[g>>2]=e+-1;N=44;break c}e=c[a+7062408>>2]|0;if((f|0)==1)e=ue(e,b,L)|0;else e=ve(e,b,L)|0;if((e|0)<0)break b;e=a+16|0;if((c[a>>2]|0)==1?(K=d[L>>0]|0,(c[e>>2]|0)!=(K|0)):0){c[M>>2]=(c[J>>2]|0)==1?4281:4288;c[M+4>>2]=K;Me(3,4293,M)}c[e>>2]=d[L>>0];c[g>>2]=c[a+7062392>>2];N=44;break}default:N=44}while(0);if((N|0)==44){e=a+36|0;g=a+40|0;k=a+20|0;f=a+4834144|0;if((xe(b,c[e>>2]|0,c[g>>2]|0,c[a+4>>2]|0,c[a>>2]|0,c[a+12>>2]|0,c[a+16>>2]|0,c[k>>2]|0,f,0)|0)<0){e=-1;break}}l=a+15416|0;m=a+15408|0;if((fe(c[e>>2]|0,c[g>>2]|0,f,c[k>>2]|0,1e6,70,1.0,l,m)|0)>=0?(je(b,c[e>>2]|0,c[g>>2]|0,c[a+4>>2]|0,l,c[m>>2]|0,c[a+7062384>>2]|0,c[k>>2]|0,c[a+24>>2]|0,(c[a+32>>2]|0)+184|0,+h[a+7062416>>3],a+48|0,P,c[a+7062424>>2]|0)|0)>=0:0)N=47;else e=-1}while(0);d:do if((N|0)==47){t=a+28|0;if((c[t>>2]|0)==1){ee(a);e=0;break}u=a+4818296|0;r=a+24|0;q=c[u>>2]|0;if((q|0)>0){s=0;do{f=c[P>>2]|0;g=a+4818304+(s*264|0)+56|0;k=a+4818304+(s*264|0)+64|0;if((f|0)>0){o=+(c[a+4818304+(s*264|0)>>2]|0);e=-1;l=0;n=.5;while(1){j=+(c[a+48+(l<<8)>>2]|0);R=o/j;if(!(R<.7|R>1.43)?(R=+h[a+48+(l<<8)+56>>3]-+h[g>>3],O=+h[a+48+(l<<8)+64>>3]-+h[k>>3],O=(R*R+O*O)/j,O=(f|0)){p=e;break}else n=j}}else p=-1;e:do if((p|0)>-1){m=c[r>>2]|0;switch(m|0){case 2:case 1:case 0:break;case 4:case 3:{g=a+48+(p<<8)+40|0;j=+h[a+4818304+(s*264|0)+40>>3];if(!(+h[g>>3]>3]<+h[f>>3]))break e}else{f=a+4818304+(s*264|0)+48|0;e=a+48+(p<<8)+48|0}h[g>>3]=j;c[a+48+(p<<8)+8>>2]=c[a+4818304+(s*264|0)+8>>2];h[e>>3]=+h[f>>3];c[a+48+(p<<8)+12>>2]=c[a+4818304+(s*264|0)+12>>2];e=-1;n=1.0e8;g=0;while(1){j=0.0;f=0;do{b=(f+g|0)%4|0;o=+h[a+4818304+(s*264|0)+168+(f<<4)>>3]-+h[a+48+(p<<8)+168+(b<<4)>>3];R=+h[a+4818304+(s*264|0)+168+(f<<4)+8>>3]-+h[a+48+(p<<8)+168+(b<<4)+8>>3];j=j+(o*o+R*R);f=f+1|0}while((f|0)!=4);f=j>2]=(b+(c[a+4818304+(s*264|0)+20>>2]|0)|0)%4|0;c[a+48+(p<<8)+24>>2]=(b+(c[a+4818304+(s*264|0)+24>>2]|0)|0)%4|0;break e}default:{e=-1;break d}}e=a+48+(p<<8)+32|0;o=+h[a+4818304+(s*264|0)+32>>3];if(+h[e>>3]>3]=o;l=c[a+4818304+(s*264|0)+4>>2]|0;c[a+48+(p<<8)+4>>2]=l;g=a+4818304+(s*264|0)+16|0;e=-1;n=1.0e8;k=0;while(1){j=0.0;f=0;do{b=(f+k|0)%4|0;S=+h[a+4818304+(s*264|0)+168+(f<<4)>>3]-+h[a+48+(p<<8)+168+(b<<4)>>3];R=+h[a+4818304+(s*264|0)+168+(f<<4)+8>>3]-+h[a+48+(p<<8)+168+(b<<4)+8>>3];j=j+(S*S+R*R);f=f+1|0}while((f|0)!=4);if(j>2]|0)|0)%4|0;else j=n;k=k+1|0;if((k|0)==4)break;else n=j}c[a+48+(p<<8)+16>>2]=e;if(m>>>0<2){c[a+48+(p<<8)+8>>2]=l;h[a+48+(p<<8)+40>>3]=o;c[a+48+(p<<8)+20>>2]=e;break}else{c[a+48+(p<<8)+12>>2]=l;h[a+48+(p<<8)+48>>3]=o;c[a+48+(p<<8)+24>>2]=e;break}}}while(0);s=s+1|0}while((s|0)<(q|0))}ee(a);if((c[u>>2]|0)>0){g=0;e=0;do{f=a+4818304+(g*264|0)|0;N=a+4818304+(g*264|0)+256|0;b=(c[N>>2]|0)+1|0;c[N>>2]=b;if((b|0)<4){if((g|0)!=(e|0))ik(a+4818304+(e*264|0)|0,f|0,264)|0;e=e+1|0}g=g+1|0}while((g|0)<(c[u>>2]|0))}else e=0;c[u>>2]=e;e=c[P>>2]|0;f:do if((e|0)>0){m=0;do{k=a+48+(m<<8)|0;g=c[a+48+(m<<8)+4>>2]|0;if((g|0)>=0){l=c[u>>2]|0;g:do if((l|0)>0){f=0;do{if((c[a+4818304+(f*264|0)+4>>2]|0)==(g|0))break g;f=f+1|0}while((f|0)<(l|0))}else f=0;while(0);if((f|0)==(l|0)){if((l|0)==60)break f;c[u>>2]=l+1}ik(a+4818304+(f*264|0)|0,k|0,256)|0;c[a+4818304+(f*264|0)+256>>2]=1}m=m+1|0;e=c[P>>2]|0}while((m|0)<(e|0))}while(0);if((c[t>>2]|0)!=2?(c[u>>2]|0)>0:0){l=0;while(1){g=a+4818304+(l*264|0)+56|0;k=a+4818304+(l*264|0)+64|0;h:do if((e|0)>0){n=+(c[a+4818304+(l*264|0)>>2]|0);f=0;do{j=+(c[a+48+(f<<8)>>2]|0);S=n/j;if(!(S<.7|S>1.43)?(R=+h[a+48+(f<<8)+56>>3]-+h[g>>3],S=+h[a+48+(f<<8)+64>>3]-+h[k>>3],(R*R+S*S)/j<.5):0)break h;f=f+1|0}while((f|0)<(e|0))}else f=0;while(0);if((f|0)==(e|0)){ik(a+48+(e<<8)|0,a+4818304+(l*264|0)|0,256)|0;e=(c[P>>2]|0)+1|0;c[P>>2]=e}l=l+1|0;if((l|0)>=(c[u>>2]|0)){e=0;break}}}else e=0}while(0);i=Q;return e|0}function ee(a){a=a|0;var b=0,d=0,e=0,f=0;switch(c[a+24>>2]|0){case 1:case 0:{d=c[a+44>>2]|0;if((d|0)>0){e=0;do{b=a+48+(e<<8)+4|0;if((c[b>>2]|0)>-1?+h[a+48+(e<<8)+32>>3]<.5:0){c[a+48+(e<<8)+8>>2]=-1;c[b>>2]=-1;c[a+48+(e<<8)+236>>2]=6}e=e+1|0}while((e|0)<(d|0))}break}case 2:{d=c[a+44>>2]|0;if((d|0)>0){e=0;do{b=a+48+(e<<8)+4|0;if((c[b>>2]|0)>-1?+h[a+48+(e<<8)+32>>3]<.5:0){c[a+48+(e<<8)+12>>2]=-1;c[b>>2]=-1;c[a+48+(e<<8)+236>>2]=6}e=e+1|0}while((e|0)<(d|0))}break}default:{e=c[a+44>>2]|0;if((e|0)>0){f=0;do{b=a+48+(f<<8)+8|0;if((c[b>>2]|0)>-1?+h[a+48+(f<<8)+40>>3]<.5:0){c[b>>2]=-1;d=0}else d=1;b=a+48+(f<<8)+12|0;if(((c[b>>2]|0)>-1?+h[a+48+(f<<8)+48>>3]<.5:0)?(c[b>>2]=-1,(d|0)==0):0)c[a+48+(f<<8)+236>>2]=6;f=f+1|0}while((f|0)<(e|0))}}}return}function fe(a,b,d,e,f,g,j,k,l){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;j=+j;k=k|0;l=l|0;var m=0.0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0.0;L=i;i=i+96|0;F=L+56|0;H=L+48|0;G=L+8|0;I=L;K=(e|0)==1;if(K){a=(a|0)/2|0;b=(b|0)/2|0;f=(f|0)/4|0;g=(g|0)/4|0}c[l>>2]=0;C=d+8|0;D=a+-2|0;z=b+-2|0;A=d+1179664|0;a:do if((c[C>>2]|0)>0){B=0;while(1){w=d+12+(B<<2)|0;y=c[w>>2]|0;b:do if(((((!((y|0)<(g|0)|(y|0)>(f|0))?(E=d+131084+(B<<4)|0,(c[E>>2]|0)!=1):0)?(c[d+131084+(B<<4)+4>>2]|0)!=(D|0):0)?(c[d+131084+(B<<4)+8>>2]|0)!=1:0)?(c[d+131084+(B<<4)+12>>2]|0)!=(z|0):0)?(ge(c[d>>2]|0,a,0,A,B+1|0,E,k+((c[l>>2]|0)*80048|0)|0)|0)>=0:0){t=c[w>>2]|0;x=c[l>>2]|0;u=k+(x*80048|0)+28|0;b=c[u>>2]|0;v=k+(x*80048|0)+40028|0;n=c[v>>2]|0;y=k+(x*80048|0)+24|0;o=(c[y>>2]|0)+-1|0;if((o|0)>1){r=0;s=1;e=0;while(1){p=(c[k+(x*80048|0)+28+(s<<2)>>2]|0)-b|0;p=$(p,p)|0;q=(c[k+(x*80048|0)+40028+(s<<2)>>2]|0)-n|0;p=($(q,q)|0)+p|0;q=(p|0)>(r|0);e=q?s:e;s=s+1|0;if((s|0)>=(o|0))break;else r=q?p:r}}else e=0;m=+(t|0)/.75*.01*j;c[H>>2]=0;c[I>>2]=0;c:do if((he(u,v,0,e,m,F,H)|0)>=0?(he(u,v,e,(c[y>>2]|0)+-1|0,m,G,I)|0)>=0:0){b=c[H>>2]|0;n=c[I>>2]|0;do if((b|0)==1&(n|0)==1){b=c[G>>2]|0;n=c[F>>2]|0}else{if((b|0)>1&(n|0)==0){b=(e|0)/2|0;c[I>>2]=0;c[H>>2]=0;if((he(u,v,0,b,m,F,H)|0)<0)break c;if((he(u,v,b,e,m,G,I)|0)<0)break c;if(!((c[H>>2]|0)==1&(c[I>>2]|0)==1))break c;b=e;n=c[F>>2]|0;e=c[G>>2]|0;break}if(!((b|0)==0&(n|0)>1))break c;b=(e+-1+(c[y>>2]|0)|0)/2|0;c[I>>2]=0;c[H>>2]=0;if((he(u,v,e,b,m,F,H)|0)<0)break c;if((he(u,v,b,(c[y>>2]|0)+-1|0,m,G,I)|0)<0)break c;if(!((c[H>>2]|0)==1&(c[I>>2]|0)==1))break c;b=c[G>>2]|0;n=e;e=c[F>>2]|0}while(0);c[k+(x*80048|0)+80028>>2]=0;c[k+(x*80048|0)+80032>>2]=n;c[k+(x*80048|0)+80036>>2]=e;c[k+(x*80048|0)+80040>>2]=b;c[k+(x*80048|0)+80044>>2]=(c[y>>2]|0)+-1;c[k+((c[l>>2]|0)*80048|0)>>2]=c[w>>2];y=c[l>>2]|0;h[k+(y*80048|0)+8>>3]=+h[d+655376+(B<<4)>>3];h[k+(y*80048|0)+16>>3]=+h[d+655376+(B<<4)+8>>3];y=y+1|0;c[l>>2]=y;if((y|0)==60){e=60;break a}else break b}while(0)}while(0);B=B+1|0;if((B|0)>=(c[C>>2]|0)){J=4;break}}}else J=4;while(0);if((J|0)==4)e=c[l>>2]|0;if((e|0)>0){o=0;do{a=o;o=o+1|0;g=k+(a*80048|0)+16|0;n=k+(a*80048|0)|0;if((o|0)<(e|0)){j=+h[k+(a*80048|0)+8>>3];f=o;do{M=j-+h[k+(f*80048|0)+8>>3];m=+h[g>>3]-+h[k+(f*80048|0)+16>>3];m=M*M+m*m;e=c[n>>2]|0;a=k+(f*80048|0)|0;b=c[a>>2]|0;if((e|0)>(b|0)){if(m<+((e|0)/4|0|0))c[a>>2]=0}else if(m<+((b|0)/4|0|0))c[n>>2]=0;f=f+1|0;e=c[l>>2]|0}while((f|0)<(e|0))}}while((o|0)<(e|0))}if((e|0)>0){f=0;do{if(!(c[k+(f*80048|0)>>2]|0)){a=f+1|0;if((a|0)<(e|0)){e=f;b=a;while(1){ik(k+(e*80048|0)|0,k+(b*80048|0)|0,80048)|0;e=c[l>>2]|0;a=b+1|0;if((a|0)<(e|0)){e=b;b=a}else break}}e=e+-1|0;c[l>>2]=e}f=f+1|0}while((f|0)<(e|0))}if(K&(e|0)>0){b=0;while(1){c[k>>2]=c[k>>2]<<2;e=k+8|0;h[e>>3]=+h[e>>3]*2.0;e=k+16|0;h[e>>3]=+h[e>>3]*2.0;e=k+24|0;if((c[e>>2]|0)>0){a=0;do{K=k+28+(a<<2)|0;c[K>>2]=c[K>>2]<<1;K=k+40028+(a<<2)|0;c[K>>2]=c[K>>2]<<1;a=a+1|0}while((a|0)<(c[e>>2]|0))}b=b+1|0;if((b|0)>=(c[l>>2]|0))break;else k=k+80048|0}}i=L;return 0}function ge(a,d,e,f,g,h,j){a=a|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;w=i;i=i+80032|0;p=w+16|0;o=w+8|0;l=w;u=w+40024|0;v=w+24|0;t=c[h+8>>2]|0;e=c[h>>2]|0;h=c[h+4>>2]|0;a:do if((e|0)<=(h|0)){k=e;e=a+(($(t,d)|0)+e<<1)|0;while(1){s=b[e>>1]|0;if(s<<16>>16>0?(c[f+((s<<16>>16)+-1<<2)>>2]|0)==(g|0):0){n=k;break}if((k|0)<(h|0)){k=k+1|0;e=e+2|0}else{x=6;break a}}q=j+24|0;c[q>>2]=1;r=j+28|0;c[r>>2]=n;s=j+40028|0;c[s>>2]=t;f=t;m=n;k=1;e=5;while(1){h=(e+5|0)%8|0;e=0;while(1){g=c[776+(h<<2)>>2]|0;l=c[808+(h<<2)>>2]|0;if((b[a+(l+m+($(g+f|0,d)|0)<<1)>>1]|0)>0){e=g;g=h;break}e=e+1|0;h=(h+1|0)%8|0;if((e|0)>=8){x=11;break}}if((x|0)==11){x=0;if((e|0)==8){x=13;break}l=c[808+(h<<2)>>2]|0;e=c[776+(h<<2)>>2]|0;g=h}c[j+28+(k<<2)>>2]=l+m;h=c[q>>2]|0;c[j+40028+(h<<2)>>2]=e+(c[j+40028+(h+-1<<2)>>2]|0);e=c[q>>2]|0;h=j+28+(e<<2)|0;if((c[h>>2]|0)==(n|0)?(c[j+40028+(e<<2)>>2]|0)==(t|0):0){f=e;x=16;break}k=e+1|0;c[q>>2]=k;if((k|0)==9999){x=19;break}f=c[j+40028+(e<<2)>>2]|0;m=c[h>>2]|0;e=g}if((x|0)==13){Me(3,4347,o);e=-1;break}else if((x|0)==16){if((f|0)>1){l=0;g=1;h=0;while(1){e=(c[j+28+(g<<2)>>2]|0)-n|0;e=$(e,e)|0;k=(c[j+40028+(g<<2)>>2]|0)-t|0;e=($(k,k)|0)+e|0;k=(e|0)>(l|0);h=k?g:h;g=g+1|0;if((g|0)>=(f|0))break;else l=k?e:l}}else h=0;if((h|0)>0){e=0;do{c[u+(e<<2)>>2]=c[j+28+(e<<2)>>2];c[v+(e<<2)>>2]=c[j+40028+(e<<2)>>2];e=e+1|0}while((e|0)<(h|0))}if((h|0)<(f|0)){e=h;do{t=e-h|0;c[j+28+(t<<2)>>2]=c[j+28+(e<<2)>>2];c[j+40028+(t<<2)>>2]=c[j+40028+(e<<2)>>2];e=e+1|0}while((e|0)<(c[q>>2]|0))}if((h|0)>0){e=0;do{t=e-h|0;c[j+28+((c[q>>2]|0)+t<<2)>>2]=c[u+(e<<2)>>2];c[j+40028+((c[q>>2]|0)+t<<2)>>2]=c[v+(e<<2)>>2];e=e+1|0}while((e|0)<(h|0))}c[j+28+(c[q>>2]<<2)>>2]=c[r>>2];c[j+40028+(c[q>>2]<<2)>>2]=c[s>>2];c[q>>2]=(c[q>>2]|0)+1;e=0;break}else if((x|0)==19){Me(3,4354,p);e=-1;break}}else x=6;while(0);if((x|0)==6){Me(3,4340,l);e=-1}i=w;return e|0}function he(a,b,d,e,f,g,h){a=a|0;b=b|0;d=d|0;e=e|0;f=+f;g=g|0;h=h|0;var i=0,j=0.0,k=0.0,l=0,m=0.0,n=0,o=0.0,p=0,q=0,r=0,s=0.0;i=c[b+(e<<2)>>2]|0;q=c[b+(d<<2)>>2]|0;o=+(i-q|0);l=c[a+(d<<2)>>2]|0;r=c[a+(e<<2)>>2]|0;m=+(l-r|0);k=+(($(r,q)|0)-($(l,i)|0)|0);i=d+1|0;if((i|0)<(e|0)){j=0.0;l=i;do{s=k+(o*+(c[a+(l<<2)>>2]|0)+m*+(c[b+(l<<2)>>2]|0));s=s*s;r=s>j;j=r?s:j;i=r?l:i;l=l+1|0}while((l|0)<(e|0))}else j=0.0;if(j/(o*o+m*m)>f)if(((he(a,b,d,i,f,g,h)|0)>=0?(n=c[h>>2]|0,(n|0)<=5):0)?(c[g+(n<<2)>>2]=i,c[h>>2]=(c[h>>2]|0)+1,(he(a,b,i,e,f,g,h)|0)>=0):0)p=7;else i=-1;else p=7;if((p|0)==7)i=0;return i|0}function ie(a,b,d,e,f,j,k){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;j=j|0;k=k|0;var l=0,m=0.0,n=0,o=0.0,p=0.0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;y=i;i=i+16|0;t=y+4|0;u=y;v=nf(2)|0;w=nf(2)|0;x=Re(2,2)|0;q=0;a:while(1){r=q;q=q+1|0;s=c[e+(q<<2)>>2]|0;l=c[e+(r<<2)>>2]|0;p=+(s+1-l|0)*.05+.5;l=~~(+(l|0)+p);s=~~(+(s|0)-p)-l|0;n=s+1|0;d=Re(n,2)|0;if((s|0)>-1){s=0;do{z=s+l|0;if((mf(f,+(c[a+(z<<2)>>2]|0),+(c[b+(z<<2)>>2]|0),t,u)|0)<0){l=10;break a}z=s<<1;A=c[d>>2]|0;h[A+(z<<3)>>3]=+g[t>>2];h[A+((z|1)<<3)>>3]=+g[u>>2];s=s+1|0}while((s|0)<(n|0))}if((Ye(d,x,v,w)|0)<0){l=10;break}A=c[x>>2]|0;o=+h[A+8>>3];h[j+(r*24|0)>>3]=o;p=-+h[A>>3];h[j+(r*24|0)+8>>3]=p;A=c[w>>2]|0;h[j+(r*24|0)+16>>3]=-(o*+h[A>>3]+ +h[A+8>>3]*p);We(d)|0;if((q|0)>=4){l=7;break}}b:do if((l|0)==7){We(x)|0;of(w)|0;of(v)|0;q=0;while(1){d=(q+3|0)%4|0;l=j+(d*24|0)|0;m=+h[j+(q*24|0)+8>>3];n=j+(q*24|0)|0;o=+h[j+(d*24|0)+8>>3];p=+h[l>>3]*m-+h[n>>3]*o;if(+O(+p)<.0001){d=-1;break b}A=j+(q*24|0)+16|0;z=j+(d*24|0)+16|0;h[k+(q<<4)>>3]=(o*+h[A>>3]-m*+h[z>>3])/p;h[k+(q<<4)+8>>3]=(+h[n>>3]*+h[z>>3]-+h[l>>3]*+h[A>>3])/p;q=q+1|0;if((q|0)>=4){d=0;break}}}else if((l|0)==10){We(d)|0;We(x)|0;of(w)|0;of(v)|0;d=-1}while(0);i=y;return d|0}function je(a,b,d,e,f,j,k,l,m,n,o,p,q,r){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=+o;p=p|0;q=q|0;r=r|0;var s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;F=i;i=i+16|0;D=F+4|0;E=F;z=m>>>0<2;A=(m|0)==2;if((j|0)>0){C=0;s=0;do{c[p+(s<<8)>>2]=c[f+(C*80048|0)>>2];if((mf(n,+h[f+(C*80048|0)+8>>3],+h[f+(C*80048|0)+16>>3],D,E)|0)>=0?(h[p+(s<<8)+56>>3]=+g[D>>2],h[p+(s<<8)+64>>3]=+g[E>>2],B=p+(s<<8)+168|0,(ie(f+(C*80048|0)+28|0,f+(C*80048|0)+40028|0,c[f+(C*80048|0)+24>>2]|0,f+(C*80048|0)+80028|0,n,p+(s<<8)+72|0,B)|0)>=0):0){t=p+(s<<8)+8|0;u=p+(s<<8)+20|0;v=p+(s<<8)+40|0;w=p+(s<<8)+12|0;x=p+(s<<8)+24|0;y=p+(s<<8)+48|0;switch(De(k,l,m,a,b,d,e,n,B,o,t,u,v,w,x,y,r,p+(s<<8)+240|0,p+(s<<8)+248|0)|0){case 0:{c[p+(s<<8)+236>>2]=0;break}case-1:{c[p+(s<<8)+236>>2]=2;break}case-2:{c[p+(s<<8)+236>>2]=3;break}case-3:{c[p+(s<<8)+236>>2]=4;break}case-4:{c[p+(s<<8)+236>>2]=5;break}case-5:{c[p+(s<<8)+236>>2]=9;break}case-6:{c[p+(s<<8)+236>>2]=1;break}default:{}}if(!z){if(A){c[p+(s<<8)+4>>2]=c[w>>2];c[p+(s<<8)+16>>2]=c[x>>2];h[p+(s<<8)+32>>3]=+h[y>>3]}}else{c[p+(s<<8)+4>>2]=c[t>>2];c[p+(s<<8)+16>>2]=c[u>>2];h[p+(s<<8)+32>>3]=+h[v>>3]}s=s+1|0}C=C+1|0}while((C|0)<(j|0))}else s=0;c[q>>2]=s;i=F;return 0}function ke(a,b,d,e){a=a|0;b=b|0;d=+d;e=e|0;var f=0,g=0,j=0,k=0,l=0,m=0,n=0.0,o=0,p=0;k=i;i=i+288|0;m=k+200|0;l=k+104|0;f=k+264|0;j=k+8|0;g=k;o=c[b+16>>2]|0;p=(4-o|0)%4|0;h[m>>3]=+h[b+168+(p<<4)>>3];h[m+8>>3]=+h[b+168+(p<<4)+8>>3];p=(5-o|0)%4|0;h[m+16>>3]=+h[b+168+(p<<4)>>3];h[m+24>>3]=+h[b+168+(p<<4)+8>>3];p=(6-o|0)%4|0;h[m+32>>3]=+h[b+168+(p<<4)>>3];h[m+40>>3]=+h[b+168+(p<<4)+8>>3];o=(7-o|0)%4|0;h[m+48>>3]=+h[b+168+(o<<4)>>3];h[m+56>>3]=+h[b+168+(o<<4)+8>>3];n=d*-.5;h[l>>3]=n;d=d*.5;h[l+8>>3]=d;h[l+16>>3]=0.0;h[l+24>>3]=d;h[l+32>>3]=d;h[l+40>>3]=0.0;h[l+48>>3]=d;h[l+56>>3]=n;h[l+64>>3]=0.0;h[l+72>>3]=n;h[l+80>>3]=n;h[l+88>>3]=0.0;c[f>>2]=m;c[f+4>>2]=l;c[f+8>>2]=4;if((Ef(c[a>>2]|0,m,l,4,j)|0)<0)d=1.0e8;else{p=(zf(c[a>>2]|0,f,j,e,g)|0)<0;d=p?1.0e8:+h[g>>3]}i=k;return+d}function le(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=+e;f=f|0;var g=0,j=0,k=0,l=0,m=0,n=0.0,o=0,p=0;j=i;i=i+192|0;m=j+104|0;l=j+8|0;k=j+168|0;g=j;o=c[b+16>>2]|0;p=(4-o|0)%4|0;h[m>>3]=+h[b+168+(p<<4)>>3];h[m+8>>3]=+h[b+168+(p<<4)+8>>3];p=(5-o|0)%4|0;h[m+16>>3]=+h[b+168+(p<<4)>>3];h[m+24>>3]=+h[b+168+(p<<4)+8>>3];p=(6-o|0)%4|0;h[m+32>>3]=+h[b+168+(p<<4)>>3];h[m+40>>3]=+h[b+168+(p<<4)+8>>3];o=(7-o|0)%4|0;h[m+48>>3]=+h[b+168+(o<<4)>>3];h[m+56>>3]=+h[b+168+(o<<4)+8>>3];n=e*-.5;h[l>>3]=n;e=e*.5;h[l+8>>3]=e;h[l+16>>3]=0.0;h[l+24>>3]=e;h[l+32>>3]=e;h[l+40>>3]=0.0;h[l+48>>3]=e;h[l+56>>3]=n;h[l+64>>3]=0.0;h[l+72>>3]=n;h[l+80>>3]=n;h[l+88>>3]=0.0;c[k>>2]=m;c[k+4>>2]=l;c[k+8>>2]=4;b=(zf(c[a>>2]|0,k,d,f,g)|0)<0;i=j;return+(b?1.0e8:+h[g>>3])}function me(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0;p=i;i=i+32|0;m=p+20|0;n=p;j=Uj(f<<4)|0;c[m>>2]=j;if(!j){Me(3,5472,p+8|0);rb(1)}k=Uj(f*24|0)|0;l=m+4|0;c[l>>2]=k;if(!k){Me(3,5472,p+16|0);rb(1)}if((f|0)>0){o=0;do{h[j+(o<<4)>>3]=+h[d+(o<<4)>>3];h[j+(o<<4)+8>>3]=+h[d+(o<<4)+8>>3];h[k+(o*24|0)>>3]=+h[e+(o*24|0)>>3];h[k+(o*24|0)+8>>3]=+h[e+(o*24|0)+8>>3];h[k+(o*24|0)+16>>3]=+h[e+(o*24|0)+16>>3];o=o+1|0}while((o|0)<(f|0))}c[m+8>>2]=f;if((zf(c[a>>2]|0,m,b,g,n)|0)<0)h[n>>3]=1.0e8;Vj(c[m>>2]|0);Vj(c[l>>2]|0);i=p;return+ +h[n>>3]}function ne(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0;p=i;i=i+32|0;m=p+20|0;n=p;j=Uj(f<<4)|0;c[m>>2]=j;if(!j){Me(3,5472,p+8|0);rb(1)}k=Uj(f*24|0)|0;l=m+4|0;c[l>>2]=k;if(!k){Me(3,5472,p+16|0);rb(1)}if((f|0)>0){o=0;do{h[j+(o<<4)>>3]=+h[d+(o<<4)>>3];h[j+(o<<4)+8>>3]=+h[d+(o<<4)+8>>3];h[k+(o*24|0)>>3]=+h[e+(o*24|0)>>3];h[k+(o*24|0)+8>>3]=+h[e+(o*24|0)+8>>3];h[k+(o*24|0)+16>>3]=+h[e+(o*24|0)+16>>3];o=o+1|0}while((o|0)<(f|0))}c[m+8>>2]=f;if((Bf(c[a>>2]|0,m,b,g,n)|0)<0)h[n>>3]=1.0e8;Vj(c[m>>2]|0);Vj(c[l>>2]|0);i=p;return+ +h[n>>3]}function oe(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;f=Uj(2080)|0;a:do if(f){c[f+2068>>2]=d;b:do if(!e){switch(d|0){case 5:case 12:case 13:case 14:break;default:{g=4;break b}}c[f+2076>>2]=0}else g=4;while(0);do if((g|0)==4){g=Uj($(b,a)|0)|0;c[f>>2]=g;if(!g){Vj(f);f=0;break a}else{c[f+2076>>2]=1;break}}while(0);c[f+2072>>2]=e;c[f+4>>2]=0;c[f+8>>2]=a;c[f+12>>2]=b}while(0);return f|0}function pe(a){a=a|0;if(a){if(c[a+2076>>2]|0)Vj(c[a>>2]|0);Vj(c[a+4>>2]|0);Vj(a)}return}function qe(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0;k=i;i=i+16|0;g=k;f=c[b+2068>>2]|0;a:do switch(f|0){case 5:case 12:case 13:case 14:if(!(c[b+2072>>2]|0)){c[b>>2]=e;f=0;break a}else{ik(c[b>>2]|0,e|0,$(c[b+12>>2]|0,c[b+8>>2]|0)|0)|0;f=0;break a}default:{if((f&-2|0)==2){f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=(((d[e+(j|1)>>0]|0)+(d[e+j>>0]|0)+(d[e+(j|2)>>0]|0)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break a}else j=j+4|0}}if((f&-3|0)==4){f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=(((d[e+(j|2)>>0]|0)+(d[e+(j|1)>>0]|0)+(d[e+(j|3)>>0]|0)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break a}else j=j+4|0}}if(f>>>0<2){f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=(((d[e+(j+1)>>0]|0)+(d[e+j>>0]|0)+(d[e+(j+2)>>0]|0)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break a}else j=j+3|0}}switch(f|0){case 8:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=a[e+j>>0]|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}case 7:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){a[(c[b>>2]|0)+h>>0]=a[e+(j|1)>>0]|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}case 9:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){m=d[e+j>>0]|0;l=d[e+(j|1)>>0]|0;a[(c[b>>2]|0)+h>>0]=(((m&248)+10+(m<<5&224)+(l>>>3&28)+(l<<3&248)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}case 10:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){l=d[e+j>>0]|0;m=d[e+(j|1)>>0]|0;a[(c[b>>2]|0)+h>>0]=(((l&248)+12+(l<<5&224)+(m>>>3&24)+(m<<2&248)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}case 11:{f=b+8|0;g=b+12|0;if(!($(c[g>>2]|0,c[f>>2]|0)|0)){f=0;break a}else{h=0;j=0}while(1){m=d[e+j>>0]|0;a[(c[b>>2]|0)+h>>0]=(((m&240)+24+(m<<4&240)+((d[e+(j|1)>>0]|0)&240)|0)>>>0)/3|0;h=h+1|0;if(h>>>0>=($(c[g>>2]|0,c[f>>2]|0)|0)>>>0){f=0;break}else j=j+2|0}break}default:{Me(3,4361,g);f=-1;break a}}}}while(0);i=k;return f|0}function re(a,b){a=a|0;b=b|0;var e=0,f=0;if((a|0)!=0&(b|0)!=0?(qe(a,b)|0)>=0:0){ek(a+16|0,0,1024)|0;b=c[a>>2]|0;f=$(c[a+12>>2]|0,c[a+8>>2]|0)|0;e=b+f|0;if((f|0)>0){do{f=a+16+((d[b>>0]|0)<<2)|0;c[f>>2]=(c[f>>2]|0)+1;b=b+1|0}while(b>>>0>>0);b=0}else b=0}else b=-1;return b|0}function se(a,b){a=a|0;b=b|0;var d=0;b=re(a,b)|0;if((b|0)>=0){b=0;d=0;do{b=(c[a+16+(d<<2)>>2]|0)+b|0;c[a+1040+(d<<2)>>2]=b;d=d+1|0}while((d|0)!=256);b=0}return b|0}function te(b,d,e,f){b=b|0;d=d|0;e=+e;f=f|0;var g=0,h=0,i=0;if(!(e<0.0|e>1.0)){d=se(b,d)|0;if((d|0)>=0){i=~~(+($(c[b+12>>2]|0,c[b+8>>2]|0)|0)*e)>>>0;d=0;while(1){h=d&255;g=c[b+1040+(h<<2)>>2]|0;if(g>>>0>>0)d=d+1<<24>>24;else break}if((g|0)==(i|0))do d=d+1<<24>>24;while((c[b+1040+((d&255)<<2)>>2]|0)==(i|0));a[f>>0]=((d&255)+h|0)>>>1;d=0}}else d=-1;return d|0}function ue(a,b,c){a=a|0;b=b|0;c=c|0;return te(a,b,.5,c)|0}function ve(b,d,e){b=b|0;d=d|0;e=e|0;var f=0.0,g=0,h=0.0,i=0.0,j=0.0,k=0.0,l=0,m=0.0,n=0.0;d=re(b,d)|0;if((d|0)>=0){d=1;f=0.0;do{f=f+ +(($(c[b+16+(d<<2)>>2]|0,d)|0)>>>0);d=d+1|0}while((d|0)!=256);k=+($(c[b+12>>2]|0,c[b+8>>2]|0)|0);l=0;h=0.0;d=0;j=0.0;m=0.0;while(1){g=c[b+16+(l<<2)>>2]|0;m=m+ +(g>>>0);if(m!=0.0){i=k-m;if(i==0.0)break;h=h+ +(($(l,g)|0)>>>0);n=h/m-(f-h)/i;i=n*(m*i*n);if(i>j)d=l&255;else i=j}else i=j;if((l&255)<<24>>24==-1)break;else{l=l+1|0;j=i}}a[e>>0]=d;d=0}return d|0}function we(b,e,f,g){b=b|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;e=re(b,e)|0;do if((e|0)>=0){t=b+4|0;if(!(c[t>>2]|0)){e=b+8|0;h=b+12|0;s=Uj($(c[h>>2]|0,c[e>>2]|0)|0)|0;c[t>>2]=s;if(!s){e=-1;break}else s=e}else{s=b+8|0;h=b+12|0}q=f>>1;r=0-q|0;e=c[h>>2]|0;if((e|0)>0){n=(q|0)<(r|0);o=(q|0)<(r|0);p=0;do{e=c[s>>2]|0;if((e|0)>0){m=0;do{if(n){i=0;f=0}else{i=0;l=r;f=0;while(1){j=l+p|0;if(((j|0)>=0?(j|0)<(c[h>>2]|0):0)?(u=$(e,j)|0,!o):0){k=r;while(1){j=k+m|0;if((j|0)>-1&(j|0)<(e|0)){i=i+1|0;f=(d[(c[b>>2]|0)+(u+j)>>0]|0)+f|0}if((k|0)<(q|0))k=k+1|0;else break}}if((l|0)<(q|0))l=l+1|0;else break}}l=($(e,p)|0)+m|0;a[(c[t>>2]|0)+l>>0]=(f|0)/(i|0)|0;m=m+1|0;e=c[s>>2]|0}while((m|0)<(e|0))}p=p+1|0;e=c[h>>2]|0}while((p|0)<(e|0))}if((g|0)!=0?($(e,c[s>>2]|0)|0)>0:0){e=0;do{b=(c[t>>2]|0)+e|0;a[b>>0]=(d[b>>0]|0)+g;e=e+1|0}while((e|0)<($(c[h>>2]|0,c[s>>2]|0)|0));e=0}else e=0}while(0);return e|0}function xe(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0;a:do switch(e|0){case 0:{switch(f|0){case 1:{if(j){k=Fc(a,b,c,j,i)|0;break a}switch(h|0){case 0:{if(d>>>0<2){k=wc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=yc(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=Bc(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=Cc(a,b,c,g,i)|0;break a}case 8:{k=Ec(a,b,c,g,i)|0;break a}case 7:{k=Dc(a,b,c,g,i)|0;break a}case 9:{k=xc(a,b,c,g,i)|0;break a}case 10:{k=Ac(a,b,c,g,i)|0;break a}case 11:{k=zc(a,b,c,g,i)|0;break a}default:rb(0)}break}case 1:{if(d>>>0<2){k=nc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=pc(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=sc(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=tc(a,b,c,g,i)|0;break a}case 8:{k=vc(a,b,c,g,i)|0;break a}case 7:{k=uc(a,b,c,g,i)|0;break a}case 9:{k=oc(a,b,c,g,i)|0;break a}case 10:{k=rc(a,b,c,g,i)|0;break a}case 11:{k=qc(a,b,c,g,i)|0;break a}default:rb(0)}break}default:rb(0)}break}case 0:{if(j){k=Yc(a,b,c,j,i)|0;break a}switch(h|0){case 0:{if(d>>>0<2){k=Pc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=Rc(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=Uc(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=Vc(a,b,c,g,i)|0;break a}case 8:{k=Xc(a,b,c,g,i)|0;break a}case 7:{k=Wc(a,b,c,g,i)|0;break a}case 9:{k=Qc(a,b,c,g,i)|0;break a}case 10:{k=Tc(a,b,c,g,i)|0;break a}case 11:{k=Sc(a,b,c,g,i)|0;break a}default:rb(0)}break}case 1:{if(d>>>0<2){k=Gc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=Ic(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=Lc(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=Mc(a,b,c,g,i)|0;break a}case 8:{k=Oc(a,b,c,g,i)|0;break a}case 7:{k=Nc(a,b,c,g,i)|0;break a}case 9:{k=Hc(a,b,c,g,i)|0;break a}case 10:{k=Kc(a,b,c,g,i)|0;break a}case 11:{k=Jc(a,b,c,g,i)|0;break a}default:rb(0)}break}default:rb(0)}break}default:rb(0)}break}case 1:{switch(f|0){case 1:{if(j){k=pd(a,b,c,j,i)|0;break a}switch(h|0){case 0:{if(d>>>0<2){k=gd(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=id(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=ld(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=md(a,b,c,g,i)|0;break a}case 8:{k=od(a,b,c,g,i)|0;break a}case 7:{k=nd(a,b,c,g,i)|0;break a}case 9:{k=hd(a,b,c,g,i)|0;break a}case 10:{k=kd(a,b,c,g,i)|0;break a}case 11:{k=jd(a,b,c,g,i)|0;break a}default:rb(0)}break}case 1:{if(d>>>0<2){k=Zc(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=$c(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=cd(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=dd(a,b,c,g,i)|0;break a}case 8:{k=fd(a,b,c,g,i)|0;break a}case 7:{k=ed(a,b,c,g,i)|0;break a}case 9:{k=_c(a,b,c,g,i)|0;break a}case 10:{k=bd(a,b,c,g,i)|0;break a}case 11:{k=ad(a,b,c,g,i)|0;break a}default:rb(0)}break}default:rb(0)}break}case 0:{if(j){k=Id(a,b,c,j,i)|0;break a}switch(h|0){case 0:{if(d>>>0<2){k=zd(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=Bd(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=Ed(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=Fd(a,b,c,g,i)|0;break a}case 8:{k=Hd(a,b,c,g,i)|0;break a}case 7:{k=Gd(a,b,c,g,i)|0;break a}case 9:{k=Ad(a,b,c,g,i)|0;break a}case 10:{k=Dd(a,b,c,g,i)|0;break a}case 11:{k=Cd(a,b,c,g,i)|0;break a}default:rb(0)}break}case 1:{if(d>>>0<2){k=qd(a,b,c,g,i)|0;break a}if((d&-2|0)==2){k=sd(a,b,c,g,i)|0;break a}if((d&-3|0)==4){k=vd(a,b,c,g,i)|0;break a}switch(d|0){case 5:case 12:case 13:case 14:{k=wd(a,b,c,g,i)|0;break a}case 8:{k=yd(a,b,c,g,i)|0;break a}case 7:{k=xd(a,b,c,g,i)|0;break a}case 9:{k=rd(a,b,c,g,i)|0;break a}case 10:{k=ud(a,b,c,g,i)|0;break a}case 11:{k=td(a,b,c,g,i)|0;break a}default:rb(0)}break}default:rb(0)}break}default:rb(0)}break}default:rb(0)}while(0);return k|0}function ye(a,b){a=a|0;b=b|0;var d=0;if((a|0)!=0?(d=a+7062384|0,(c[d>>2]|0)==0):0){c[d>>2]=b;d=0}else d=-1;return d|0}function ze(a){a=a|0;var b=0;if((a|0)!=0?(b=a+7062384|0,(c[b>>2]|0)!=0):0){c[b>>2]=0;b=0}else b=-1;return b|0}function Ae(){return Be(16,50)|0}function Be(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;r=i;i=i+64|0;q=r+56|0;p=r+48|0;j=r+40|0;h=r+32|0;g=r+24|0;f=r+16|0;e=r+8|0;d=r;a:do if(!((a+-16|0)>>>0>48|(b|0)<1)){n=Uj(32)|0;if(!n){Me(3,5472,d);rb(1)}c[n>>2]=0;c[n+4>>2]=b;c[n+28>>2]=a;m=Uj(b<<2)|0;c[n+8>>2]=m;if(!m){Me(3,5472,e);rb(1)}d=b<<4;l=Uj(d)|0;c[n+12>>2]=l;if(!l){Me(3,5472,f);rb(1)}f=Uj(d)|0;k=n+20|0;c[k>>2]=f;if(!f){Me(3,5472,g);rb(1)}d=b<<5;g=Uj(d)|0;c[n+16>>2]=g;if(!g){Me(3,5472,h);rb(1)}h=Uj(d)|0;c[n+24>>2]=h;if(!h){Me(3,5472,j);rb(1)}e=$(a,a)|0;d=e*12|0;e=e<<2;if((b|0)>0){a=0;b:while(1){c[m+(a<<2)>>2]=0;f=a<<2;h=0;while(1){if((h|0)>=4)break;j=Uj(d)|0;g=h+f|0;c[l+(g<<2)>>2]=j;if(!j){d=18;break b}j=Uj(e)|0;c[(c[k>>2]|0)+(g<<2)>>2]=j;if(!j){d=20;break b}else h=h+1|0}a=a+1|0;if((a|0)>=(b|0)){o=n;break a}}if((d|0)==18){Me(3,5472,p);rb(1)}else if((d|0)==20){Me(3,5472,q);rb(1)}}else o=n}else o=0;while(0);i=r;return o|0}function Ce(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0;if(!a)b=-1;else{b=a+4|0;d=a+8|0;e=a+12|0;f=a+20|0;if((c[b>>2]|0)>0){g=0;do{if(c[(c[d>>2]|0)+(g<<2)>>2]|0)Le(a,g)|0;h=g<<2;Vj(c[(c[e>>2]|0)+(h<<2)>>2]|0);Vj(c[(c[f>>2]|0)+(h<<2)>>2]|0);i=1+h|0;Vj(c[(c[e>>2]|0)+(i<<2)>>2]|0);Vj(c[(c[f>>2]|0)+(i<<2)>>2]|0);i=2+h|0;Vj(c[(c[e>>2]|0)+(i<<2)>>2]|0);Vj(c[(c[f>>2]|0)+(i<<2)>>2]|0);h=3+h|0;Vj(c[(c[e>>2]|0)+(h<<2)>>2]|0);Vj(c[(c[f>>2]|0)+(h<<2)>>2]|0);g=g+1|0}while((g|0)<(c[b>>2]|0))}Vj(a);b=0}return b|0}function De(b,e,f,g,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x){b=b|0;e=e|0;f=f|0;g=g|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=+o;p=p|0;q=q|0;r=r|0;s=s|0;t=t|0;u=u|0;v=v|0;w=w|0;x=x|0;var y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0;L=i;i=i+12448|0;A=L+12440|0;z=L+8|0;J=L;I=L+12312|0;K=L+24|0;do if((f+-2|0)>>>0<3){if((v|0)!=2830){y=v&255;if((Ee(e,2,y,y*3|0,g,j,k,l,m,n,o,K)|0)<0){c[s>>2]=-1;y=-6;break}y=Fe(K,y,s,t,u,v,w)|0;if(!x)break;c[x>>2]=0;c[x+4>>2]=0;break}if((Ee(e,2,14,42,g,j,k,l,m,n,.875,K)|0)<0){c[s>>2]=-1;y=-6;break}c[z>>2]=0;c[z+4>>2]=182;c[z+8>>2]=195;c[z+12>>2]=13;v=a[K+(c[z>>2]|0)>>0]|0;y=(v&255)>0?v:0;v=(v&255)<255?v:-1;H=a[K+(c[z+4>>2]|0)>>0]|0;y=(H&255)>(y&255)?H:y;v=(H&255)<(v&255)?H:v;H=a[K+(c[z+8>>2]|0)>>0]|0;y=(H&255)>(y&255)?H:y;v=(H&255)<(v&255)?H:v;H=a[K+(c[z+12>>2]|0)>>0]|0;y=((H&255)>(y&255)?H:y)&255;v=((H&255)<(v&255)?H:v)&255;a:do if((y-v|0)>=30){H=(y+v|0)>>>1;a[A>>0]=(d[K+(c[z>>2]|0)>>0]|0)>>>0>>0&1;a[A+1>>0]=(d[K+(c[z+4>>2]|0)>>0]|0)>>>0>>0&1;a[A+2>>0]=(d[K+(c[z+8>>2]|0)>>0]|0)>>>0>>0&1;a[A+3>>0]=(d[K+(c[z+12>>2]|0)>>0]|0)>>>0>>0&1;v=0;while(1){y=v+1|0;if(((a[A+v>>0]|0)==1?(a[A+((y|0)%4|0)>>0]|0)==1:0)?(a[A+((v+2|0)%4|0)>>0]|0)==0:0){G=v;break}if((y|0)<4)v=y;else{G=y;break}}switch(G|0){case 4:{c[t>>2]=0;h[u>>3]=-1.0;y=-3;v=0;z=0;break a}case 0:{z=119;y=255;v=0;do{D=v+-3|0;B=(v&-2|0)==12;C=v*14|0;A=0;do{if(((A+-3|D)>>>0>=8?(F=A&-2,(A|v)>>>0>=2):0)?!(B&((F|0)==0|(F|0)==12)):0){E=(d[K+(A+C)>>0]|0)-H|0;a[I+z>>0]=E>>>31;E=(E|0)>-1?E:0-E|0;z=z+-1|0;y=(E|0)<(y|0)?E:y}A=A+1|0}while((A|0)!=14);v=v+1|0}while((v|0)!=14);break}case 1:{z=119;y=255;v=0;do{D=v+-3|0;C=v&-2;B=(C|0)==0;C=(C|0)==12;A=13;while(1){if(((A+-3|D)>>>0>=8?(E=(A&-2|0)==12,!(B&E)):0)?!(C&(A>>>0<2|E)):0){F=(d[K+((A*14|0)+v)>>0]|0)-H|0;a[I+z>>0]=F>>>31;F=(F|0)>-1?F:0-F|0;z=z+-1|0;y=(F|0)<(y|0)?F:y}if((A|0)>0)A=A+-1|0;else break}v=v+1|0}while((v|0)!=14);break}case 2:{v=119;y=255;D=13;while(1){B=D+-3|0;C=D>>>0<2|(D&-2|0)==12;A=D*14|0;z=13;while(1){if((z+-3|B)>>>0>=8?!((z|D)>>>0<2|C&(z&-2|0)==12):0){F=(d[K+(z+A)>>0]|0)-H|0; a[I+v>>0]=F>>>31;F=(F|0)>-1?F:0-F|0;v=v+-1|0;y=(F|0)<(y|0)?F:y}if((z|0)>0)z=z+-1|0;else break}if((D|0)>0)D=D+-1|0;else break}break}case 3:{v=119;y=255;D=13;while(1){C=D+-3|0;B=D&-2;A=(B|0)==12;B=(B|0)==0;z=0;do{if(((z+-3|C)>>>0>=8?!(A&z>>>0<2|(z|D)>>>0<2):0)?!(B&(z&-2|0)==12):0){F=(d[K+((z*14|0)+D)>>0]|0)-H|0;a[I+v>>0]=F>>>31;F=(F|0)>-1?F:0-F|0;v=v+-1|0;y=(F|0)<(y|0)?F:y}z=z+1|0}while((z|0)!=14);if((D|0)>0)D=D+-1|0;else break}break}default:y=255}c[t>>2]=G;h[u>>3]=(y|0)>30?1.0:+(y|0)/30.0;y=Ie(2830,0,0,I,J)|0;if((y|0)<0){y=-4;v=0;z=0}else{if(w)c[w>>2]=y;z=J;y=0;v=c[z>>2]|0;z=c[z+4>>2]|0}}else{c[t>>2]=0;h[u>>3]=-1.0;y=-2;v=0;z=0}while(0);if((y|0)<0){c[s>>2]=-1;break}if((v|0)==-1&(z|0)==-1){c[s>>2]=-1;y=-5;break}c[s>>2]=(v&-32768|0)==0&0==0?v&32767:0;if(!x)y=0;else{y=x;c[y>>2]=v;c[y+4>>2]=z;y=0}}else y=1;while(0);b:do switch(f|0){case 0:case 1:case 3:case 4:{if(!b){c[p>>2]=-1;v=-1;break b}v=b+28|0;z=c[v>>2]|0;A=z<<2;switch(f|0){case 0:case 3:if((Ee(e,0,z,A,g,j,k,l,m,n,o,K)|0)<0){c[p>>2]=-1;v=-6;break b}else{v=Ge(b,0,K,c[v>>2]|0,p,q,r)|0;break b}default:if((Ee(e,1,z,A,g,j,k,l,m,n,o,K)|0)<0){c[p>>2]=-1;v=-6;break b}else{v=Ge(b,1,K,c[v>>2]|0,p,q,r)|0;break b}}}default:v=1}while(0);if((y|0)!=1){if((v|0)!=1)y=(v&y|0)<0?v:0}else y=v;i=L;return y|0}function _j(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0;k=i;i=i+16|0;b=k+8|0;h=k+4|0;d=k;c[h>>2]=a;do if(a>>>0>=212){g=(a>>>0)/210|0;e=g*210|0;c[d>>2]=a-e;b=($j(3712,3904,d,b)|0)-3712>>2;f=b;b=(c[3712+(b<<2)>>2]|0)+e|0;a:while(1){e=5;while(1){if(e>>>0>=47){e=211;j=8;break}d=c[3520+(e<<2)>>2]|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=106;break a}if((b|0)==($(a,d)|0))break;else e=e+1|0}b:do if((j|0)==8)while(1){j=0;d=(b>>>0)/(e>>>0)|0;if(d>>>0>>0){j=105;break a}if((b|0)==($(d,e)|0))break b;d=e+10|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+12|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+16|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+18|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+22|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+28|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+30|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+36|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+40|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+42|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+46|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+52|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+58|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+60|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+66|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+70|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+72|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+78|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+82|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+88|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+96|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+100|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+102|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+106|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+108|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+112|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+120|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+126|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+130|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+136|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+138|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+142|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+148|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+150|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+156|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+162|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+166|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+168|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+172|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+178|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+180|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+186|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+190|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+192|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+196|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+198|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break b;d=e+208|0;a=(b>>>0)/(d>>>0)|0;if(a>>>0>>0){j=105;break a}if((b|0)==($(a,d)|0))break;else{e=e+210|0;j=8}}while(0);e=f+1|0;b=(e|0)==48;e=b?0:e;b=(b&1)+g|0;f=e;g=b;b=(c[3712+(e<<2)>>2]|0)+(b*210|0)|0}if((j|0)==105){c[h>>2]=b;break}else if((j|0)==106){c[h>>2]=b;break}}else b=c[($j(3520,3712,h,b)|0)>>2]|0;while(0);i=k;return b|0}function $j(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=c[d>>2]|0;e=a;d=b-a>>2;a:while(1){while(1){if(!d)break a;a=(d|0)/2|0;if((c[e+(a<<2)>>2]|0)>>>0>>0)break;else d=a}e=e+(a+1<<2)|0;d=d+-1-a|0}return e|0}function ak(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0;if(e>>>0>4294967279)oi(b);if(e>>>0<11){a[b>>0]=e<<1;b=b+1|0}else{g=e+16&-16;f=Kh(g)|0;c[b+8>>2]=f;c[b>>2]=g|1;c[b+4>>2]=e;b=f}ik(b|0,d|0,e|0)|0;a[b+e>>0]=0;return}function bk(b){b=b|0;if(a[b>>0]&1)Lh(c[b+8>>2]|0);return}function ck(){}function dk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;d=b-d-(c>>>0>a>>>0|0)>>>0;return(D=d,a-c>>>0|0)|0}function ek(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;f=b+e|0;if((e|0)>=20){d=d&255;h=b&3;i=d|d<<8|d<<16|d<<24;g=f&~3;if(h){h=b+4-h|0;while((b|0)<(h|0)){a[b>>0]=d;b=b+1|0}}while((b|0)<(g|0)){c[b>>2]=i;b=b+4|0}}while((b|0)<(f|0)){a[b>>0]=d;b=b+1|0}return b-e|0}function fk(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){D=b<>>32-c;return a<>>0;return(D=b+d+(c>>>0>>0|0)>>>0,c|0)|0}function hk(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){D=b>>>c;return a>>>c|(b&(1<>>c-32|0}function ik(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;if((e|0)>=4096)return Xa(b|0,d|0,e|0)|0;f=b|0;if((b&3)==(d&3)){while(b&3){if(!e)return f|0;a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}while((e|0)>=4){c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0;e=e-4|0}}while((e|0)>0){a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}return f|0}function jk(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){D=b>>c;return a>>>c|(b&(1<>c-32|0}function kk(b){b=b|0;var c=0;c=a[m+(b&255)>>0]|0;if((c|0)<8)return c|0;c=a[m+(b>>8&255)>>0]|0;if((c|0)<8)return c+8|0;c=a[m+(b>>16&255)>>0]|0;if((c|0)<8)return c+16|0;return(a[m+(b>>>24)>>0]|0)+24|0}function lk(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;f=a&65535;e=b&65535;c=$(e,f)|0;d=a>>>16;a=(c>>>16)+($(e,d)|0)|0;e=b>>>16;b=$(e,f)|0;return(D=(a>>>16)+($(e,d)|0)+(((a&65535)+b|0)>>>16)|0,a+b<<16|c&65535|0)|0}function mk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;j=b>>31|((b|0)<0?-1:0)<<1;i=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;f=d>>31|((d|0)<0?-1:0)<<1;e=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;h=dk(j^a,i^b,j,i)|0;g=D;a=f^j;b=e^i;return dk((rk(h,g,dk(f^c,e^d,f,e)|0,D,0)|0)^a,D^b,a,b)|0}function nk(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0;f=i;i=i+16|0;j=f|0;h=b>>31|((b|0)<0?-1:0)<<1;g=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;l=e>>31|((e|0)<0?-1:0)<<1;k=((e|0)<0?-1:0)>>31|((e|0)<0?-1:0)<<1;a=dk(h^a,g^b,h,g)|0;b=D;rk(a,b,dk(l^d,k^e,l,k)|0,D,j)|0;e=dk(c[j>>2]^h,c[j+4>>2]^g,h,g)|0;d=D;i=f;return(D=d,e)|0}function ok(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=a;f=c;c=lk(e,f)|0;a=D;return(D=($(b,f)|0)+($(d,e)|0)+a|a&0,c|0|0)|0}function pk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return rk(a,b,c,d,0)|0}function qk(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;g=i;i=i+16|0;f=g|0;rk(a,b,d,e,f)|0;i=g;return(D=c[f+4>>2]|0,c[f>>2]|0)|0}function rk(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;l=a;j=b;k=j;h=d;n=e;i=n;if(!k){g=(f|0)!=0;if(!i){if(g){c[f>>2]=(l>>>0)%(h>>>0);c[f+4>>2]=0}n=0;f=(l>>>0)/(h>>>0)>>>0;return(D=n,f)|0}else{if(!g){n=0;f=0;return(D=n,f)|0}c[f>>2]=a|0;c[f+4>>2]=b&0;n=0;f=0;return(D=n,f)|0}}g=(i|0)==0;do if(h){if(!g){g=(ba(i|0)|0)-(ba(k|0)|0)|0;if(g>>>0<=31){m=g+1|0;i=31-g|0;b=g-31>>31;h=m;a=l>>>(m>>>0)&b|k<>>(m>>>0)&b;g=0;i=l<>2]=a|0;c[f+4>>2]=j|b&0;n=0;f=0;return(D=n,f)|0}g=h-1|0;if(g&h){i=(ba(h|0)|0)+33-(ba(k|0)|0)|0;p=64-i|0;m=32-i|0;j=m>>31;o=i-32|0;b=o>>31;h=i;a=m-1>>31&k>>>(o>>>0)|(k<>>(i>>>0))&b;b=b&k>>>(i>>>0);g=l<>>(o>>>0))&j|l<>31;break}if(f){c[f>>2]=g&l;c[f+4>>2]=0}if((h|0)==1){o=j|b&0;p=a|0|0;return(D=o,p)|0}else{p=kk(h|0)|0;o=k>>>(p>>>0)|0;p=k<<32-p|l>>>(p>>>0)|0;return(D=o,p)|0}}else{if(g){if(f){c[f>>2]=(k>>>0)%(h>>>0);c[f+4>>2]=0}o=0;p=(k>>>0)/(h>>>0)>>>0;return(D=o,p)|0}if(!l){if(f){c[f>>2]=0;c[f+4>>2]=(k>>>0)%(i>>>0)}o=0;p=(k>>>0)/(i>>>0)>>>0;return(D=o,p)|0}g=i-1|0;if(!(g&i)){if(f){c[f>>2]=a|0;c[f+4>>2]=g&k|b&0}o=0;p=k>>>((kk(i|0)|0)>>>0);return(D=o,p)|0}g=(ba(i|0)|0)-(ba(k|0)|0)|0;if(g>>>0<=30){b=g+1|0;i=31-g|0;h=b;a=k<>>(b>>>0);b=k>>>(b>>>0);g=0;i=l<>2]=a|0;c[f+4>>2]=j|b&0;o=0;p=0;return(D=o,p)|0}while(0);if(!h){k=i;j=0;i=0}else{m=d|0|0;l=n|e&0;k=gk(m|0,l|0,-1,-1)|0;d=D;j=i;i=0;do{e=j;j=g>>>31|j<<1;g=i|g<<1;e=a<<1|e>>>31|0;n=a>>>31|b<<1|0;dk(k,d,e,n)|0;p=D;o=p>>31|((p|0)<0?-1:0)<<1;i=o&1;a=dk(e,n,o&m,(((p|0)<0?-1:0)>>31|((p|0)<0?-1:0)<<1)&l)|0;b=D;h=h-1|0}while((h|0)!=0);k=j;j=0}h=0;if(f){c[f>>2]=a;c[f+4>>2]=b}o=(g|0)>>>31|(k|h)<<1|(h<<1|g>>>31)&0|j;p=(g<<1|0>>>31)&-2|i;return(D=o,p)|0}function sk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Qb[a&15](b|0,c|0,d|0)|0}function tk(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;Rb[a&3](b|0,c|0,d|0,e|0,f|0)}function uk(a,b,c){a=a|0;b=b|0;c=c|0;return+Sb[a&1](b|0,c|0)}function vk(a,b,c){a=a|0;b=b|0;c=+c;Tb[a&3](b|0,+c)}function wk(a,b){a=a|0;b=b|0;return+Ub[a&3](b|0)}function xk(a){a=a|0;return Vb[a&1]()|0}function yk(a,b){a=a|0;b=b|0;Wb[a&15](b|0)}function zk(a,b,c){a=a|0;b=b|0;c=c|0;Xb[a&7](b|0,c|0)}function Ak(a,b){a=a|0;b=b|0;return Yb[a&31](b|0)|0}function Bk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Zb[a&1](b|0,c|0,d|0)}function Ck(a){a=a|0;_b[a&0]()}function Dk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;$b[a&3](b|0,c|0,+d)}function Ek(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return ac[a&1](b|0,c|0,d|0,e|0)|0}function Fk(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;bc[a&3](b|0,c|0,d|0,e|0,f|0,g|0)}function Gk(a,b,c){a=a|0;b=b|0;c=c|0;return cc[a&15](b|0,c|0)|0}function Hk(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;dc[a&3](b|0,c|0,d|0,e|0)}function Ik(a,b,c){a=a|0;b=b|0;c=c|0;ca(0);return 0}function Jk(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;ca(1)}function Kk(a,b){a=a|0;b=b|0;ca(2);return 0.0}function Lk(a,b){a=a|0;b=+b;ca(3)}function Mk(a){a=a|0;ca(4);return 0.0}function Nk(){ca(5);return 0}function Ok(a){a=a|0;ca(6)}function Pk(a,b){a=a|0;b=b|0;ca(7)}function Qk(a){a=a|0;ca(8);return 0}function Rk(a,b,c){a=a|0;b=b|0;c=c|0;ca(9)}function Sk(){ca(10)}function Tk(a,b,c){a=a|0;b=b|0;c=+c;ca(11)}function Uk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(12);return 0}function Vk(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ca(13)}function Wk(a,b){a=a|0;b=b|0;ca(14);return 0}function Xk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(15)}var Qb=[Ik,Zh,_h,Qj,Qi,Pi,Ri,Ag,sg,qg,rg,yg,kh,jh,Oi,Mj];var Rb=[Jk,ki,ji,gi];var Sb=[Kk,dh];var Tb=[Lk,Wf,Yf,ag];var Ub=[Mk,Xf,Zf,bg];var Vb=[Nk,Nf];var Wb=[Ok,Mh,Nh,Sh,Vh,Th,Uh,Wh,Xh,Yh,Mf,Xg,Yg,Ij,Jj,Ok];var Xb=[Pk,ig,gg,_f,cg,eg,ng,gh];var Yb=[Qk,Oh,Ni,Pf,Vf,Qf,wg,xg,mg,lg,jg,hg,$f,dg,fg,og,fh,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk,Qk];var Zb=[Rk,ch];var _b=[Sk];var $b=[Tk,eh,bh,Tk];var ac=[Uk,mh];var bc=[Vk,ni,mi,li];var cc=[Wk,Df,Sf,Tf,Uf,tg,vg,ug,zg,kg,lh,hh,Wk,Wk,Wk,Wk];var dc=[Xk,ai,bi,di];return{_i64Subtract:dk,_fflush:Yi,_i64Add:gk,_memset:ek,_malloc:Uj,_memcpy:ik,___getTypeName:Ah,_bitshift64Lshr:hk,_free:Vj,___errno_location:qi,_bitshift64Shl:fk,__GLOBAL__sub_I_ARToolKitJS_cpp:Wg,__GLOBAL__sub_I_bind_cpp:Ch,runPostSets:ck,stackAlloc:ec,stackSave:fc,stackRestore:gc,establishStackSpace:hc,setThrew:ic,setTempRet0:lc,getTempRet0:mc,dynCall_iiii:sk,dynCall_viiiii:tk,dynCall_dii:uk,dynCall_vid:vk,dynCall_di:wk,dynCall_i:xk,dynCall_vi:yk,dynCall_vii:zk,dynCall_ii:Ak,dynCall_viii:Bk,dynCall_v:Ck,dynCall_viid:Dk,dynCall_iiiii:Ek,dynCall_viiiiii:Fk,dynCall_iii:Gk,dynCall_viiii:Hk}}(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var __GLOBAL__sub_I_bind_cpp=Module["__GLOBAL__sub_I_bind_cpp"]=asm["__GLOBAL__sub_I_bind_cpp"];var _fflush=Module["_fflush"]=asm["_fflush"];var __GLOBAL__sub_I_ARToolKitJS_cpp=Module["__GLOBAL__sub_I_ARToolKitJS_cpp"]=asm["__GLOBAL__sub_I_ARToolKitJS_cpp"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _memset=Module["_memset"]=asm["_memset"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var _malloc=Module["_malloc"]=asm["_malloc"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var ___getTypeName=Module["___getTypeName"]=asm["___getTypeName"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _free=Module["_free"]=asm["_free"];var ___errno_location=Module["___errno_location"]=asm["___errno_location"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_viiiii=Module["dynCall_viiiii"]=asm["dynCall_viiiii"];var dynCall_dii=Module["dynCall_dii"]=asm["dynCall_dii"];var dynCall_vid=Module["dynCall_vid"]=asm["dynCall_vid"];var dynCall_di=Module["dynCall_di"]=asm["dynCall_di"];var dynCall_i=Module["dynCall_i"]=asm["dynCall_i"];var dynCall_vi=Module["dynCall_vi"]=asm["dynCall_vi"];var dynCall_vii=Module["dynCall_vii"]=asm["dynCall_vii"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_viii=Module["dynCall_viii"]=asm["dynCall_viii"];var dynCall_v=Module["dynCall_v"]=asm["dynCall_v"];var dynCall_viid=Module["dynCall_viid"]=asm["dynCall_viid"];var dynCall_iiiii=Module["dynCall_iiiii"]=asm["dynCall_iiiii"];var dynCall_viiiiii=Module["dynCall_viiiiii"]=asm["dynCall_viiiiii"];var dynCall_iii=Module["dynCall_iii"]=asm["dynCall_iii"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];Runtime.stackAlloc=asm["stackAlloc"];Runtime.stackSave=asm["stackSave"];Runtime.stackRestore=asm["stackRestore"];Runtime.establishStackSpace=asm["establishStackSpace"];Runtime.setTempRet0=asm["setTempRet0"];Runtime.getTempRet0=asm["getTempRet0"];function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;var preloadStartTime=null;var calledMain=false;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};Module["callMain"]=Module.callMain=function callMain(args){assert(runDependencies==0,"cannot call main when async dependencies remain! (listen on __ATMAIN__)");assert(__ATPRERUN__.length==0,"cannot call main when preRun functions remain to be called");args=args||[];ensureInitRuntime();var argc=args.length+1;function pad(){for(var i=0;i<4-1;i++){argv.push(0)}}var argv=[allocate(intArrayFromString(Module["thisProgram"]),"i8",ALLOC_NORMAL)];pad();for(var i=0;i0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();if(Module["_main"]&&shouldRunNow)Module["callMain"](args);postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=Module.run=run;function exit(status,implicit){if(implicit&&Module["noExitRuntime"]){return}if(Module["noExitRuntime"]){}else{ABORT=true;EXITSTATUS=status;STACKTOP=initialStackTop;exitRuntime();if(Module["onExit"])Module["onExit"](status)}if(ENVIRONMENT_IS_NODE){process["stdout"]["once"]("drain",function(){process["exit"](status)});console.log(" ");setTimeout(function(){process["exit"](status)},500)}else if(ENVIRONMENT_IS_SHELL&&typeof quit==="function"){quit(status)}throw new ExitStatus(status)}Module["exit"]=Module.exit=exit;var abortDecorators=[];function abort(what){if(what!==undefined){Module.print(what);Module.printErr(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;var extra="\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.";var output="abort("+what+") at "+stackTrace()+extra;if(abortDecorators){abortDecorators.forEach(function(decorator){output=decorator(output,what)})}throw output}Module["abort"]=Module.abort=abort;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}var shouldRunNow=true;if(Module["noInitialRun"]){shouldRunNow=false}run();(function(){"use strict";var ARController=function(width,height,camera){var id;var w=width,h=height;this.orientation="landscape";this.listeners={};if(typeof width!=="number"){var image=width;camera=height;w=image.videoWidth||image.width;h=image.videoHeight||image.height;this.image=image}this.defaultMarkerWidth=1;this.patternMarkers={};this.barcodeMarkers={};this.transform_mat=new Float32Array(16);this.canvas=document.createElement("canvas");this.canvas.width=w;this.canvas.height=h;this.ctx=this.canvas.getContext("2d");this.videoWidth=w;this.videoHeight=h;if(typeof camera==="string"){var self=this;this.cameraParam=new ARCameraParam(camera,function(){self._initialize()},function(err){console.error("ARController: Failed to load ARCameraParam",err)})}else{this.cameraParam=camera;this._initialize()}};ARController.prototype.dispose=function(){artoolkit.teardown(this.id);for(var t in this){this[t]=null}};ARController.prototype.process=function(image){this.detectMarker(image);var markerNum=this.getMarkerNum();var k,o;for(k in this.patternMarkers){o=this.patternMarkers[k];o.inPrevious=o.inCurrent;o.inCurrent=false}for(k in this.barcodeMarkers){o=this.barcodeMarkers[k];o.inPrevious=o.inCurrent;o.inCurrent=false}for(var i=0;i-1&&(markerInfo.id===markerInfo.idPatt||markerInfo.idMatrix===-1)){visible=this.trackPatternMarkerId(markerInfo.idPatt);markerType=artoolkit.PATTERN_MARKER;if(markerInfo.dir!==markerInfo.dirPatt){this.setMarkerInfoDir(i,markerInfo.dirPatt)}}else if(markerInfo.idMatrix>-1){visible=this.trackBarcodeMarkerId(markerInfo.idMatrix);markerType=artoolkit.BARCODE_MARKER;if(markerInfo.dir!==markerInfo.dirMatrix){this.setMarkerInfoDir(i,markerInfo.dirMatrix)}}if(markerType!==artoolkit.UNKNOWN_MARKER&&visible.inPrevious){this.getTransMatSquareCont(i,visible.markerWidth,visible.matrix,visible.matrix)}else{this.getTransMatSquare(i,visible.markerWidth,visible.matrix)}visible.inCurrent=true;this.transMatToGLMat(visible.matrix,this.transform_mat);this.dispatchEvent({name:"getMarker",target:this,data:{index:i,type:markerType,marker:markerInfo,matrix:this.transform_mat}})}var multiMarkerCount=this.getMultiMarkerCount();for(var i=0;i=0){visible=true;this.dispatchEvent({name:"getMultiMarker",target:this,data:{multiMarkerId:i,matrix:this.transform_mat}});break}}if(visible){for(var j=0;j-1){this.listeners[name].splice(index,1)}}};ARController.prototype.dispatchEvent=function(event){var listeners=this.listeners[event.name];if(listeners){for(var i=0;i-1){writeStringToFS(filename,url,writeCallback)}else{ajax(url,filename,writeCallback)}}function writeStringToFS(target,string,callback){var byteArray=new Uint8Array(string.length);for(var i=0;i=this.parameters.minVisibleDelay){object3d.visible=true;snapDirectlyToTarget()}}if(wasVisible===true&&targetObject3d.visible===false){var unvisibleFor=present-this._unvisibleStartedAt;if(unvisibleFor>=this.parameters.minUnvisibleDelay){object3d.visible=false}}if(this._lastLerpStepAt===null){applyOneSlerpStep();this._lastLerpStepAt=present}else{var nStepsToDo=Math.floor((present-this._lastLerpStepAt)/this.parameters.lerpStepDelay);for(var i=0;iwebvr.info for more info."); -}else{alert("Your browser does not support WebVR. See webvr.info for assistance.")}this._tangoContext={vrDisplay:null,vrPointCloud:null,frameData:new VRFrameData};navigator.getVRDisplays().then(function(vrDisplays){if(vrDisplays.length===0)alert("no vrDisplays available");var vrDisplay=_this._tangoContext.vrDisplay=vrDisplays[0];console.log("vrDisplays.displayName :",vrDisplay.displayName);if(vrDisplay.displayName==="Tango VR Device"){_this._tangoContext.vrPointCloud=new THREE.WebAR.VRPointCloud(vrDisplay,true)}onCompleted()})};THREEx.ArToolkitContext.prototype._updateTango=function(srcElement){var _this=this;var arMarkersControls=this._arMarkersControls;var tangoContext=this._tangoContext;var vrDisplay=this._tangoContext.vrDisplay;if(vrDisplay===null)return;if(vrDisplay.displayName==="Tango VR Device"){var showPointCloud=true;var pointsToSkip=0;_this._tangoContext.vrPointCloud.update(showPointCloud,pointsToSkip,true)}if(this._arMarkersControls.length===0)return;var foundControls=this._arMarkersControls[0];var frameData=this._tangoContext.frameData;vrDisplay.getFrameData(frameData);if(frameData.pose.position===null)return;if(frameData.pose.orientation===null)return;var position=(new THREE.Vector3).fromArray(frameData.pose.position);var quaternion=(new THREE.Quaternion).fromArray(frameData.pose.orientation);var scale=new THREE.Vector3(1,1,1);var cameraTransformMatrix=(new THREE.Matrix4).compose(position,quaternion,scale);var modelViewMatrix=new THREE.Matrix4;modelViewMatrix.getInverse(cameraTransformMatrix);foundControls.updateWithModelViewMatrix(modelViewMatrix)};var ARjs=ARjs||{};var THREEx=THREEx||{};ARjs.Profile=THREEx.ArToolkitProfile=function(){this.reset();this.performance("default")};ARjs.Profile.prototype._guessPerformanceLabel=function(){var isMobile=navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i)?true:false;if(isMobile===true){return"phone-normal"}return"desktop-normal"};ARjs.Profile.prototype.reset=function(){this.sourceParameters={sourceType:"webcam"};this.contextParameters={cameraParametersUrl:THREEx.ArToolkitContext.baseURL+"../data/data/camera_para.dat",detectionMode:"mono"};this.defaultMarkerParameters={type:"pattern",patternUrl:THREEx.ArToolkitContext.baseURL+"../data/data/patt.hiro",changeMatrixMode:"modelViewMatrix"};return this};ARjs.Profile.prototype.performance=function(label){if(label==="default"){label=this._guessPerformanceLabel()}if(label==="desktop-fast"){this.contextParameters.canvasWidth=640*3;this.contextParameters.canvasHeight=480*3;this.contextParameters.maxDetectionRate=30}else if(label==="desktop-normal"){this.contextParameters.canvasWidth=640;this.contextParameters.canvasHeight=480;this.contextParameters.maxDetectionRate=60}else if(label==="phone-normal"){this.contextParameters.canvasWidth=80*4;this.contextParameters.canvasHeight=60*4;this.contextParameters.maxDetectionRate=30}else if(label==="phone-slow"){this.contextParameters.canvasWidth=80*3;this.contextParameters.canvasHeight=60*3;this.contextParameters.maxDetectionRate=30}else{console.assert(false,"unknonwn label "+label)}return this};ARjs.Profile.prototype.defaultMarker=function(trackingBackend){trackingBackend=trackingBackend||this.contextParameters.trackingBackend;if(trackingBackend==="artoolkit"){this.contextParameters.detectionMode="mono";this.defaultMarkerParameters.type="pattern";this.defaultMarkerParameters.patternUrl=THREEx.ArToolkitContext.baseURL+"../data/data/patt.hiro"}else if(trackingBackend==="aruco"){this.contextParameters.detectionMode="mono";this.defaultMarkerParameters.type="barcode";this.defaultMarkerParameters.barcodeValue=1001}else if(trackingBackend==="tango"){this.defaultMarkerParameters.type="barcode";this.defaultMarkerParameters.barcodeValue=1001}else console.assert(false);return this};ARjs.Profile.prototype.sourceWebcam=function(){this.sourceParameters.sourceType="webcam";delete this.sourceParameters.sourceUrl;return this};ARjs.Profile.prototype.sourceVideo=function(url){this.sourceParameters.sourceType="video";this.sourceParameters.sourceUrl=url;return this};ARjs.Profile.prototype.sourceImage=function(url){this.sourceParameters.sourceType="image";this.sourceParameters.sourceUrl=url;return this};ARjs.Profile.prototype.trackingBackend=function(trackingBackend){console.warn("stop profile.trackingBackend() obsolete function. use .trackingMethod instead");this.contextParameters.trackingBackend=trackingBackend;return this};ARjs.Profile.prototype.changeMatrixMode=function(changeMatrixMode){this.defaultMarkerParameters.changeMatrixMode=changeMatrixMode;return this};ARjs.Profile.prototype.trackingMethod=function(trackingMethod){var data=ARjs.Utils.parseTrackingMethod(trackingMethod);this.defaultMarkerParameters.markersAreaEnabled=data.markersAreaEnabled;this.contextParameters.trackingBackend=data.trackingBackend;return this};ARjs.Profile.prototype.checkIfValid=function(){if(this.contextParameters.trackingBackend==="tango"){this.sourceImage(THREEx.ArToolkitContext.baseURL+"../data/images/img.jpg")}return this};var THREEx=THREEx||{};THREEx.ArToolkitSource=function(parameters){this.parameters={sourceType:parameters.sourceType!==undefined?parameters.sourceType:"webcam",sourceUrl:parameters.sourceUrl!==undefined?parameters.sourceUrl:null,sourceWidth:parameters.sourceWidth!==undefined?parameters.sourceWidth:640,sourceHeight:parameters.sourceHeight!==undefined?parameters.sourceHeight:480,displayWidth:parameters.displayWidth!==undefined?parameters.displayWidth:640,displayHeight:parameters.displayHeight!==undefined?parameters.displayHeight:480};this.ready=false;this.domElement=null};THREEx.ArToolkitSource.prototype.init=function(onReady){var _this=this;if(this.parameters.sourceType==="image"){var domElement=this._initSourceImage(onSourceReady)}else if(this.parameters.sourceType==="video"){var domElement=this._initSourceVideo(onSourceReady)}else if(this.parameters.sourceType==="webcam"){var domElement=this._initSourceWebcam(onSourceReady)}else{console.assert(false)}this.domElement=domElement;this.domElement.style.position="absolute";this.domElement.style.top="0px";this.domElement.style.left="0px";this.domElement.style.zIndex="-2";return this;function onSourceReady(){document.body.appendChild(_this.domElement);_this.ready=true;onReady&&onReady()}};THREEx.ArToolkitSource.prototype._initSourceImage=function(onReady){var domElement=document.createElement("img");domElement.src=this.parameters.sourceUrl;domElement.width=this.parameters.sourceWidth;domElement.height=this.parameters.sourceHeight;domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";var interval=setInterval(function(){if(!domElement.naturalWidth)return;onReady();clearInterval(interval)},1e3/50);return domElement};THREEx.ArToolkitSource.prototype._initSourceVideo=function(onReady){var domElement=document.createElement("video");domElement.src=this.parameters.sourceUrl;domElement.style.objectFit="initial";domElement.autoplay=true;domElement.webkitPlaysinline=true;domElement.controls=false;domElement.loop=true;domElement.muted=true;document.body.addEventListener("click",function onClick(){document.body.removeEventListener("click",onClick);domElement.play()});domElement.width=this.parameters.sourceWidth;domElement.height=this.parameters.sourceHeight;domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";var interval=setInterval(function(){if(!domElement.videoWidth)return;onReady();clearInterval(interval)},1e3/50);return domElement};THREEx.ArToolkitSource.prototype._initSourceWebcam=function(onReady){var _this=this;var domElement=document.createElement("video");domElement.setAttribute("autoplay","");domElement.setAttribute("muted","");domElement.setAttribute("playsinline","");domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";if(navigator.mediaDevices===undefined||navigator.mediaDevices.enumerateDevices===undefined||navigator.mediaDevices.getUserMedia===undefined){alert("WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser")}navigator.mediaDevices.enumerateDevices().then(function(devices){var userMediaConstraints={audio:false,video:{facingMode:"environment",width:{ideal:_this.parameters.sourceWidth},height:{ideal:_this.parameters.sourceHeight}}};navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream){domElement.srcObject=stream;document.body.addEventListener("click",function(){domElement.play()});var interval=setInterval(function(){if(!domElement.videoWidth)return;onReady();clearInterval(interval)},1e3/50)}).catch(function(error){console.log("Can't access user media",error);alert("Can't access user media :()")})}).catch(function(err){console.log(err.name+": "+err.message)});return domElement};THREEx.ArToolkitSource.prototype.hasMobileTorch=function(){var stream=arToolkitSource.domElement.srcObject;if(stream instanceof MediaStream===false)return false;if(this._currentTorchStatus===undefined){this._currentTorchStatus=false}var videoTrack=stream.getVideoTracks()[0];if(videoTrack.getCapabilities===undefined)return false;var capabilities=videoTrack.getCapabilities();return capabilities.torch?true:false};THREEx.ArToolkitSource.prototype.toggleMobileTorch=function(){console.assert(this.hasMobileTorch()===true);var stream=arToolkitSource.domElement.srcObject;if(stream instanceof MediaStream===false){alert("enabling mobile torch is available only on webcam");return}if(this._currentTorchStatus===undefined){this._currentTorchStatus=false}var videoTrack=stream.getVideoTracks()[0];var capabilities=videoTrack.getCapabilities();if(!capabilities.torch){alert("no mobile torch is available on your camera");return}this._currentTorchStatus=this._currentTorchStatus===false?true:false;videoTrack.applyConstraints({advanced:[{torch:this._currentTorchStatus}]}).catch(function(error){console.log(error)})};THREEx.ArToolkitSource.prototype.onResizeElement=function(mirrorDomElements){var _this=this;var screenWidth=window.innerWidth;var screenHeight=window.innerHeight;if(this.domElement.nodeName==="IMG"){var sourceWidth=this.domElement.naturalWidth;var sourceHeight=this.domElement.naturalHeight}else if(this.domElement.nodeName==="VIDEO"){var sourceWidth=this.domElement.videoWidth;var sourceHeight=this.domElement.videoHeight}else{console.assert(false)}var sourceAspect=sourceWidth/sourceHeight;var screenAspect=screenWidth/screenHeight;if(screenAspect-1){writeStringToFS(filename,url,writeCallback)}else{ajax(url,filename,writeCallback)}}function writeStringToFS(target,string,callback){var byteArray=new Uint8Array(string.length);for(var i=0;i=this.parameters.minVisibleDelay){object3d.visible=true;snapDirectlyToTarget()}}if(wasVisible===true&&targetObject3d.visible===false){var unvisibleFor=present-this._unvisibleStartedAt;if(unvisibleFor>=this.parameters.minUnvisibleDelay){object3d.visible=false}}if(this._lastLerpStepAt===null){applyOneSlerpStep();this._lastLerpStepAt=present}else{var nStepsToDo=Math.floor((present-this._lastLerpStepAt)/this.parameters.lerpStepDelay);for(var i=0;iwebvr.info for more info.")}else{alert("Your browser does not support WebVR. See webvr.info for assistance."); +}this._tangoContext={vrDisplay:null,vrPointCloud:null,frameData:new VRFrameData};navigator.getVRDisplays().then(function(vrDisplays){if(vrDisplays.length===0)alert("no vrDisplays available");var vrDisplay=_this._tangoContext.vrDisplay=vrDisplays[0];console.log("vrDisplays.displayName :",vrDisplay.displayName);if(vrDisplay.displayName==="Tango VR Device"){_this._tangoContext.vrPointCloud=new THREE.WebAR.VRPointCloud(vrDisplay,true)}onCompleted()})};ARjs.Context.prototype._updateTango=function(srcElement){var _this=this;var arMarkersControls=this._arMarkersControls;var tangoContext=this._tangoContext;var vrDisplay=this._tangoContext.vrDisplay;if(vrDisplay===null)return;if(vrDisplay.displayName==="Tango VR Device"){var showPointCloud=true;var pointsToSkip=0;_this._tangoContext.vrPointCloud.update(showPointCloud,pointsToSkip,true)}if(this._arMarkersControls.length===0)return;var foundControls=this._arMarkersControls[0];var frameData=this._tangoContext.frameData;vrDisplay.getFrameData(frameData);if(frameData.pose.position===null)return;if(frameData.pose.orientation===null)return;var position=(new THREE.Vector3).fromArray(frameData.pose.position);var quaternion=(new THREE.Quaternion).fromArray(frameData.pose.orientation);var scale=new THREE.Vector3(1,1,1);var cameraTransformMatrix=(new THREE.Matrix4).compose(position,quaternion,scale);var modelViewMatrix=new THREE.Matrix4;modelViewMatrix.getInverse(cameraTransformMatrix);foundControls.updateWithModelViewMatrix(modelViewMatrix)};var ARjs=ARjs||{};var THREEx=THREEx||{};ARjs.Profile=THREEx.ArToolkitProfile=function(){this.reset();this.performance("default")};ARjs.Profile.prototype._guessPerformanceLabel=function(){var isMobile=navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i)?true:false;if(isMobile===true){return"phone-normal"}return"desktop-normal"};ARjs.Profile.prototype.reset=function(){this.sourceParameters={sourceType:"webcam"};this.contextParameters={cameraParametersUrl:THREEx.ArToolkitContext.baseURL+"../data/data/camera_para.dat",detectionMode:"mono"};this.defaultMarkerParameters={type:"pattern",patternUrl:THREEx.ArToolkitContext.baseURL+"../data/data/patt.hiro",changeMatrixMode:"modelViewMatrix"};return this};ARjs.Profile.prototype.performance=function(label){if(label==="default"){label=this._guessPerformanceLabel()}if(label==="desktop-fast"){this.contextParameters.canvasWidth=640*3;this.contextParameters.canvasHeight=480*3;this.contextParameters.maxDetectionRate=30}else if(label==="desktop-normal"){this.contextParameters.canvasWidth=640;this.contextParameters.canvasHeight=480;this.contextParameters.maxDetectionRate=60}else if(label==="phone-normal"){this.contextParameters.canvasWidth=80*4;this.contextParameters.canvasHeight=60*4;this.contextParameters.maxDetectionRate=30}else if(label==="phone-slow"){this.contextParameters.canvasWidth=80*3;this.contextParameters.canvasHeight=60*3;this.contextParameters.maxDetectionRate=30}else{console.assert(false,"unknonwn label "+label)}return this};ARjs.Profile.prototype.defaultMarker=function(trackingBackend){trackingBackend=trackingBackend||this.contextParameters.trackingBackend;if(trackingBackend==="artoolkit"){this.contextParameters.detectionMode="mono";this.defaultMarkerParameters.type="pattern";this.defaultMarkerParameters.patternUrl=THREEx.ArToolkitContext.baseURL+"../data/data/patt.hiro"}else if(trackingBackend==="aruco"){this.contextParameters.detectionMode="mono";this.defaultMarkerParameters.type="barcode";this.defaultMarkerParameters.barcodeValue=1001}else if(trackingBackend==="tango"){this.defaultMarkerParameters.type="barcode";this.defaultMarkerParameters.barcodeValue=1001}else console.assert(false);return this};ARjs.Profile.prototype.sourceWebcam=function(){this.sourceParameters.sourceType="webcam";delete this.sourceParameters.sourceUrl;return this};ARjs.Profile.prototype.sourceVideo=function(url){this.sourceParameters.sourceType="video";this.sourceParameters.sourceUrl=url;return this};ARjs.Profile.prototype.sourceImage=function(url){this.sourceParameters.sourceType="image";this.sourceParameters.sourceUrl=url;return this};ARjs.Profile.prototype.trackingBackend=function(trackingBackend){console.warn("stop profile.trackingBackend() obsolete function. use .trackingMethod instead");this.contextParameters.trackingBackend=trackingBackend;return this};ARjs.Profile.prototype.changeMatrixMode=function(changeMatrixMode){this.defaultMarkerParameters.changeMatrixMode=changeMatrixMode;return this};ARjs.Profile.prototype.trackingMethod=function(trackingMethod){var data=ARjs.Utils.parseTrackingMethod(trackingMethod);this.defaultMarkerParameters.markersAreaEnabled=data.markersAreaEnabled;this.contextParameters.trackingBackend=data.trackingBackend;return this};ARjs.Profile.prototype.checkIfValid=function(){if(this.contextParameters.trackingBackend==="tango"){this.sourceImage(THREEx.ArToolkitContext.baseURL+"../data/images/img.jpg")}return this};var ARjs=ARjs||{};var THREEx=THREEx||{};ARjs.Source=THREEx.ArToolkitSource=function(parameters){var _this=this;this.ready=false;this.domElement=null;this.parameters={sourceType:"webcam",sourceUrl:null,sourceWidth:640,sourceHeight:480,displayWidth:640,displayHeight:480};setParameters(parameters);function setParameters(parameters){if(parameters===undefined)return;for(var key in parameters){var newValue=parameters[key];if(newValue===undefined){console.warn("THREEx.ArToolkitSource: '"+key+"' parameter is undefined.");continue}var currentValue=_this.parameters[key];if(currentValue===undefined){console.warn("THREEx.ArToolkitSource: '"+key+"' is not a property of this material.");continue}_this.parameters[key]=newValue}}};ARjs.Source.prototype.init=function(onReady,onError){var _this=this;if(this.parameters.sourceType==="image"){var domElement=this._initSourceImage(onSourceReady,onError)}else if(this.parameters.sourceType==="video"){var domElement=this._initSourceVideo(onSourceReady,onError)}else if(this.parameters.sourceType==="webcam"){var domElement=this._initSourceWebcam(onSourceReady,onError)}else{console.assert(false)}this.domElement=domElement;this.domElement.style.position="absolute";this.domElement.style.top="0px";this.domElement.style.left="0px";this.domElement.style.zIndex="-2";return this;function onSourceReady(){document.body.appendChild(_this.domElement);_this.ready=true;onReady&&onReady()}};ARjs.Source.prototype._initSourceImage=function(onReady){var domElement=document.createElement("img");domElement.src=this.parameters.sourceUrl;domElement.width=this.parameters.sourceWidth;domElement.height=this.parameters.sourceHeight;domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";var interval=setInterval(function(){if(!domElement.naturalWidth)return;onReady();clearInterval(interval)},1e3/50);return domElement};ARjs.Source.prototype._initSourceVideo=function(onReady){var domElement=document.createElement("video");domElement.src=this.parameters.sourceUrl;domElement.style.objectFit="initial";domElement.autoplay=true;domElement.webkitPlaysinline=true;domElement.controls=false;domElement.loop=true;domElement.muted=true;document.body.addEventListener("click",function onClick(){document.body.removeEventListener("click",onClick);domElement.play()});domElement.width=this.parameters.sourceWidth;domElement.height=this.parameters.sourceHeight;domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";var interval=setInterval(function(){if(!domElement.videoWidth)return;onReady();clearInterval(interval)},1e3/50);return domElement};ARjs.Source.prototype._initSourceWebcam=function(onReady,onError){var _this=this;onError=onError||function(error){alert("Webcam Error\nName: "+error.name+"\nMessage: "+error.message)};var domElement=document.createElement("video");domElement.setAttribute("autoplay","");domElement.setAttribute("muted","");domElement.setAttribute("playsinline","");domElement.style.width=this.parameters.displayWidth+"px";domElement.style.height=this.parameters.displayHeight+"px";if(navigator.mediaDevices===undefined||navigator.mediaDevices.enumerateDevices===undefined||navigator.mediaDevices.getUserMedia===undefined){onError({name:"",message:"WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser"});return}navigator.mediaDevices.enumerateDevices().then(function(devices){var userMediaConstraints={audio:false,video:{facingMode:"environment",width:{ideal:_this.parameters.sourceWidth},height:{ideal:_this.parameters.sourceHeight}}};navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream){domElement.srcObject=stream;document.body.addEventListener("click",function(){domElement.play()});var interval=setInterval(function(){if(!domElement.videoWidth)return;onReady();clearInterval(interval)},1e3/50)}).catch(function(error){onError({name:error.name,message:error.message})})}).catch(function(error){onError({message:error.message})});return domElement};ARjs.Source.prototype.hasMobileTorch=function(){var stream=arToolkitSource.domElement.srcObject;if(stream instanceof MediaStream===false)return false;if(this._currentTorchStatus===undefined){this._currentTorchStatus=false}var videoTrack=stream.getVideoTracks()[0];if(videoTrack.getCapabilities===undefined)return false;var capabilities=videoTrack.getCapabilities();return capabilities.torch?true:false};ARjs.Source.prototype.toggleMobileTorch=function(){console.assert(this.hasMobileTorch()===true);var stream=arToolkitSource.domElement.srcObject;if(stream instanceof MediaStream===false){alert("enabling mobile torch is available only on webcam");return}if(this._currentTorchStatus===undefined){this._currentTorchStatus=false}var videoTrack=stream.getVideoTracks()[0];var capabilities=videoTrack.getCapabilities();if(!capabilities.torch){alert("no mobile torch is available on your camera");return}this._currentTorchStatus=this._currentTorchStatus===false?true:false;videoTrack.applyConstraints({advanced:[{torch:this._currentTorchStatus}]}).catch(function(error){console.log(error)})};ARjs.Source.prototype.onResizeElement=function(mirrorDomElements){var _this=this;var screenWidth=window.innerWidth;var screenHeight=window.innerHeight;if(this.domElement.nodeName==="IMG"){var sourceWidth=this.domElement.naturalWidth;var sourceHeight=this.domElement.naturalHeight}else if(this.domElement.nodeName==="VIDEO"){var sourceWidth=this.domElement.videoWidth;var sourceHeight=this.domElement.videoHeight}else{console.assert(false)}var sourceAspect=sourceWidth/sourceHeight;var screenAspect=screenWidth/screenHeight;if(screenAspect