text
stringlengths
3
1.05M
# coding: utf-8 """ NiFi Rest API The Rest API provides programmatic access to command and control a NiFi instance in real time. Start and stop processors, monitor queues, query provenance data, and more. Each endpoint below includes a description, definitions of the expected input and output, potential response codes, and the authorizations required to invoke each service. OpenAPI spec version: 1.15.0 Contact: [email protected] Generated by: https://github.com/swagger-api/swagger-codegen.git """ from pprint import pformat from six import iteritems import re class ConnectionDTO(object): """ NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ """ Attributes: swagger_types (dict): The key is attribute name and the value is attribute type. attribute_map (dict): The key is attribute name and the value is json key in definition. """ swagger_types = { 'id': 'str', 'versioned_component_id': 'str', 'parent_group_id': 'str', 'position': 'PositionDTO', 'source': 'ConnectableDTO', 'destination': 'ConnectableDTO', 'name': 'str', 'label_index': 'int', 'getz_index': 'int', 'selected_relationships': 'list[str]', 'available_relationships': 'list[str]', 'back_pressure_object_threshold': 'int', 'back_pressure_data_size_threshold': 'str', 'flow_file_expiration': 'str', 'prioritizers': 'list[str]', 'bends': 'list[PositionDTO]', 'load_balance_strategy': 'str', 'load_balance_partition_attribute': 'str', 'load_balance_compression': 'str', 'load_balance_status': 'str' } attribute_map = { 'id': 'id', 'versioned_component_id': 'versionedComponentId', 'parent_group_id': 'parentGroupId', 'position': 'position', 'source': 'source', 'destination': 'destination', 'name': 'name', 'label_index': 'labelIndex', 'getz_index': 'getzIndex', 'selected_relationships': 'selectedRelationships', 'available_relationships': 'availableRelationships', 'back_pressure_object_threshold': 'backPressureObjectThreshold', 'back_pressure_data_size_threshold': 'backPressureDataSizeThreshold', 'flow_file_expiration': 'flowFileExpiration', 'prioritizers': 'prioritizers', 'bends': 'bends', 'load_balance_strategy': 'loadBalanceStrategy', 'load_balance_partition_attribute': 'loadBalancePartitionAttribute', 'load_balance_compression': 'loadBalanceCompression', 'load_balance_status': 'loadBalanceStatus' } def __init__(self, id=None, versioned_component_id=None, parent_group_id=None, position=None, source=None, destination=None, name=None, label_index=None, getz_index=None, selected_relationships=None, available_relationships=None, back_pressure_object_threshold=None, back_pressure_data_size_threshold=None, flow_file_expiration=None, prioritizers=None, bends=None, load_balance_strategy=None, load_balance_partition_attribute=None, load_balance_compression=None, load_balance_status=None): """ ConnectionDTO - a model defined in Swagger """ self._id = None self._versioned_component_id = None self._parent_group_id = None self._position = None self._source = None self._destination = None self._name = None self._label_index = None self._getz_index = None self._selected_relationships = None self._available_relationships = None self._back_pressure_object_threshold = None self._back_pressure_data_size_threshold = None self._flow_file_expiration = None self._prioritizers = None self._bends = None self._load_balance_strategy = None self._load_balance_partition_attribute = None self._load_balance_compression = None self._load_balance_status = None if id is not None: self.id = id if versioned_component_id is not None: self.versioned_component_id = versioned_component_id if parent_group_id is not None: self.parent_group_id = parent_group_id if position is not None: self.position = position if source is not None: self.source = source if destination is not None: self.destination = destination if name is not None: self.name = name if label_index is not None: self.label_index = label_index if getz_index is not None: self.getz_index = getz_index if selected_relationships is not None: self.selected_relationships = selected_relationships if available_relationships is not None: self.available_relationships = available_relationships if back_pressure_object_threshold is not None: self.back_pressure_object_threshold = back_pressure_object_threshold if back_pressure_data_size_threshold is not None: self.back_pressure_data_size_threshold = back_pressure_data_size_threshold if flow_file_expiration is not None: self.flow_file_expiration = flow_file_expiration if prioritizers is not None: self.prioritizers = prioritizers if bends is not None: self.bends = bends if load_balance_strategy is not None: self.load_balance_strategy = load_balance_strategy if load_balance_partition_attribute is not None: self.load_balance_partition_attribute = load_balance_partition_attribute if load_balance_compression is not None: self.load_balance_compression = load_balance_compression if load_balance_status is not None: self.load_balance_status = load_balance_status @property def id(self): """ Gets the id of this ConnectionDTO. The id of the component. :return: The id of this ConnectionDTO. :rtype: str """ return self._id @id.setter def id(self, id): """ Sets the id of this ConnectionDTO. The id of the component. :param id: The id of this ConnectionDTO. :type: str """ self._id = id @property def versioned_component_id(self): """ Gets the versioned_component_id of this ConnectionDTO. The ID of the corresponding component that is under version control :return: The versioned_component_id of this ConnectionDTO. :rtype: str """ return self._versioned_component_id @versioned_component_id.setter def versioned_component_id(self, versioned_component_id): """ Sets the versioned_component_id of this ConnectionDTO. The ID of the corresponding component that is under version control :param versioned_component_id: The versioned_component_id of this ConnectionDTO. :type: str """ self._versioned_component_id = versioned_component_id @property def parent_group_id(self): """ Gets the parent_group_id of this ConnectionDTO. The id of parent process group of this component if applicable. :return: The parent_group_id of this ConnectionDTO. :rtype: str """ return self._parent_group_id @parent_group_id.setter def parent_group_id(self, parent_group_id): """ Sets the parent_group_id of this ConnectionDTO. The id of parent process group of this component if applicable. :param parent_group_id: The parent_group_id of this ConnectionDTO. :type: str """ self._parent_group_id = parent_group_id @property def position(self): """ Gets the position of this ConnectionDTO. The position of this component in the UI if applicable. :return: The position of this ConnectionDTO. :rtype: PositionDTO """ return self._position @position.setter def position(self, position): """ Sets the position of this ConnectionDTO. The position of this component in the UI if applicable. :param position: The position of this ConnectionDTO. :type: PositionDTO """ self._position = position @property def source(self): """ Gets the source of this ConnectionDTO. The source of the connection. :return: The source of this ConnectionDTO. :rtype: ConnectableDTO """ return self._source @source.setter def source(self, source): """ Sets the source of this ConnectionDTO. The source of the connection. :param source: The source of this ConnectionDTO. :type: ConnectableDTO """ self._source = source @property def destination(self): """ Gets the destination of this ConnectionDTO. The destination of the connection. :return: The destination of this ConnectionDTO. :rtype: ConnectableDTO """ return self._destination @destination.setter def destination(self, destination): """ Sets the destination of this ConnectionDTO. The destination of the connection. :param destination: The destination of this ConnectionDTO. :type: ConnectableDTO """ self._destination = destination @property def name(self): """ Gets the name of this ConnectionDTO. The name of the connection. :return: The name of this ConnectionDTO. :rtype: str """ return self._name @name.setter def name(self, name): """ Sets the name of this ConnectionDTO. The name of the connection. :param name: The name of this ConnectionDTO. :type: str """ self._name = name @property def label_index(self): """ Gets the label_index of this ConnectionDTO. The index of the bend point where to place the connection label. :return: The label_index of this ConnectionDTO. :rtype: int """ return self._label_index @label_index.setter def label_index(self, label_index): """ Sets the label_index of this ConnectionDTO. The index of the bend point where to place the connection label. :param label_index: The label_index of this ConnectionDTO. :type: int """ self._label_index = label_index @property def getz_index(self): """ Gets the getz_index of this ConnectionDTO. The z index of the connection. :return: The getz_index of this ConnectionDTO. :rtype: int """ return self._getz_index @getz_index.setter def getz_index(self, getz_index): """ Sets the getz_index of this ConnectionDTO. The z index of the connection. :param getz_index: The getz_index of this ConnectionDTO. :type: int """ self._getz_index = getz_index @property def selected_relationships(self): """ Gets the selected_relationships of this ConnectionDTO. The selected relationship that comprise the connection. :return: The selected_relationships of this ConnectionDTO. :rtype: list[str] """ return self._selected_relationships @selected_relationships.setter def selected_relationships(self, selected_relationships): """ Sets the selected_relationships of this ConnectionDTO. The selected relationship that comprise the connection. :param selected_relationships: The selected_relationships of this ConnectionDTO. :type: list[str] """ self._selected_relationships = selected_relationships @property def available_relationships(self): """ Gets the available_relationships of this ConnectionDTO. The relationships that the source of the connection currently supports. :return: The available_relationships of this ConnectionDTO. :rtype: list[str] """ return self._available_relationships @available_relationships.setter def available_relationships(self, available_relationships): """ Sets the available_relationships of this ConnectionDTO. The relationships that the source of the connection currently supports. :param available_relationships: The available_relationships of this ConnectionDTO. :type: list[str] """ self._available_relationships = available_relationships @property def back_pressure_object_threshold(self): """ Gets the back_pressure_object_threshold of this ConnectionDTO. The object count threshold for determining when back pressure is applied. Updating this value is a passive change in the sense that it won't impact whether existing files over the limit are affected but it does help feeder processors to stop pushing too much into this work queue. :return: The back_pressure_object_threshold of this ConnectionDTO. :rtype: int """ return self._back_pressure_object_threshold @back_pressure_object_threshold.setter def back_pressure_object_threshold(self, back_pressure_object_threshold): """ Sets the back_pressure_object_threshold of this ConnectionDTO. The object count threshold for determining when back pressure is applied. Updating this value is a passive change in the sense that it won't impact whether existing files over the limit are affected but it does help feeder processors to stop pushing too much into this work queue. :param back_pressure_object_threshold: The back_pressure_object_threshold of this ConnectionDTO. :type: int """ self._back_pressure_object_threshold = back_pressure_object_threshold @property def back_pressure_data_size_threshold(self): """ Gets the back_pressure_data_size_threshold of this ConnectionDTO. The object data size threshold for determining when back pressure is applied. Updating this value is a passive change in the sense that it won't impact whether existing files over the limit are affected but it does help feeder processors to stop pushing too much into this work queue. :return: The back_pressure_data_size_threshold of this ConnectionDTO. :rtype: str """ return self._back_pressure_data_size_threshold @back_pressure_data_size_threshold.setter def back_pressure_data_size_threshold(self, back_pressure_data_size_threshold): """ Sets the back_pressure_data_size_threshold of this ConnectionDTO. The object data size threshold for determining when back pressure is applied. Updating this value is a passive change in the sense that it won't impact whether existing files over the limit are affected but it does help feeder processors to stop pushing too much into this work queue. :param back_pressure_data_size_threshold: The back_pressure_data_size_threshold of this ConnectionDTO. :type: str """ self._back_pressure_data_size_threshold = back_pressure_data_size_threshold @property def flow_file_expiration(self): """ Gets the flow_file_expiration of this ConnectionDTO. The amount of time a flow file may be in the flow before it will be automatically aged out of the flow. Once a flow file reaches this age it will be terminated from the flow the next time a processor attempts to start work on it. :return: The flow_file_expiration of this ConnectionDTO. :rtype: str """ return self._flow_file_expiration @flow_file_expiration.setter def flow_file_expiration(self, flow_file_expiration): """ Sets the flow_file_expiration of this ConnectionDTO. The amount of time a flow file may be in the flow before it will be automatically aged out of the flow. Once a flow file reaches this age it will be terminated from the flow the next time a processor attempts to start work on it. :param flow_file_expiration: The flow_file_expiration of this ConnectionDTO. :type: str """ self._flow_file_expiration = flow_file_expiration @property def prioritizers(self): """ Gets the prioritizers of this ConnectionDTO. The comparators used to prioritize the queue. :return: The prioritizers of this ConnectionDTO. :rtype: list[str] """ return self._prioritizers @prioritizers.setter def prioritizers(self, prioritizers): """ Sets the prioritizers of this ConnectionDTO. The comparators used to prioritize the queue. :param prioritizers: The prioritizers of this ConnectionDTO. :type: list[str] """ self._prioritizers = prioritizers @property def bends(self): """ Gets the bends of this ConnectionDTO. The bend points on the connection. :return: The bends of this ConnectionDTO. :rtype: list[PositionDTO] """ return self._bends @bends.setter def bends(self, bends): """ Sets the bends of this ConnectionDTO. The bend points on the connection. :param bends: The bends of this ConnectionDTO. :type: list[PositionDTO] """ self._bends = bends @property def load_balance_strategy(self): """ Gets the load_balance_strategy of this ConnectionDTO. How to load balance the data in this Connection across the nodes in the cluster. :return: The load_balance_strategy of this ConnectionDTO. :rtype: str """ return self._load_balance_strategy @load_balance_strategy.setter def load_balance_strategy(self, load_balance_strategy): """ Sets the load_balance_strategy of this ConnectionDTO. How to load balance the data in this Connection across the nodes in the cluster. :param load_balance_strategy: The load_balance_strategy of this ConnectionDTO. :type: str """ allowed_values = ["DO_NOT_LOAD_BALANCE", "PARTITION_BY_ATTRIBUTE", "ROUND_ROBIN", "SINGLE_NODE"] if load_balance_strategy not in allowed_values: raise ValueError( "Invalid value for `load_balance_strategy` ({0}), must be one of {1}" .format(load_balance_strategy, allowed_values) ) self._load_balance_strategy = load_balance_strategy @property def load_balance_partition_attribute(self): """ Gets the load_balance_partition_attribute of this ConnectionDTO. The FlowFile Attribute to use for determining which node a FlowFile will go to if the Load Balancing Strategy is set to PARTITION_BY_ATTRIBUTE :return: The load_balance_partition_attribute of this ConnectionDTO. :rtype: str """ return self._load_balance_partition_attribute @load_balance_partition_attribute.setter def load_balance_partition_attribute(self, load_balance_partition_attribute): """ Sets the load_balance_partition_attribute of this ConnectionDTO. The FlowFile Attribute to use for determining which node a FlowFile will go to if the Load Balancing Strategy is set to PARTITION_BY_ATTRIBUTE :param load_balance_partition_attribute: The load_balance_partition_attribute of this ConnectionDTO. :type: str """ self._load_balance_partition_attribute = load_balance_partition_attribute @property def load_balance_compression(self): """ Gets the load_balance_compression of this ConnectionDTO. Whether or not data should be compressed when being transferred between nodes in the cluster. :return: The load_balance_compression of this ConnectionDTO. :rtype: str """ return self._load_balance_compression @load_balance_compression.setter def load_balance_compression(self, load_balance_compression): """ Sets the load_balance_compression of this ConnectionDTO. Whether or not data should be compressed when being transferred between nodes in the cluster. :param load_balance_compression: The load_balance_compression of this ConnectionDTO. :type: str """ allowed_values = ["DO_NOT_COMPRESS", "COMPRESS_ATTRIBUTES_ONLY", "COMPRESS_ATTRIBUTES_AND_CONTENT"] if load_balance_compression not in allowed_values: raise ValueError( "Invalid value for `load_balance_compression` ({0}), must be one of {1}" .format(load_balance_compression, allowed_values) ) self._load_balance_compression = load_balance_compression @property def load_balance_status(self): """ Gets the load_balance_status of this ConnectionDTO. The current status of the Connection's Load Balancing Activities. Status can indicate that Load Balancing is not configured for the connection, that Load Balancing is configured but inactive (not currently transferring data to another node), or that Load Balancing is configured and actively transferring data to another node. :return: The load_balance_status of this ConnectionDTO. :rtype: str """ return self._load_balance_status @load_balance_status.setter def load_balance_status(self, load_balance_status): """ Sets the load_balance_status of this ConnectionDTO. The current status of the Connection's Load Balancing Activities. Status can indicate that Load Balancing is not configured for the connection, that Load Balancing is configured but inactive (not currently transferring data to another node), or that Load Balancing is configured and actively transferring data to another node. :param load_balance_status: The load_balance_status of this ConnectionDTO. :type: str """ allowed_values = ["LOAD_BALANCE_NOT_CONFIGURED", "LOAD_BALANCE_INACTIVE", "LOAD_BALANCE_ACTIVE"] if load_balance_status not in allowed_values: raise ValueError( "Invalid value for `load_balance_status` ({0}), must be one of {1}" .format(load_balance_status, allowed_values) ) self._load_balance_status = load_balance_status def to_dict(self): """ Returns the model properties as a dict """ result = {} for attr, _ in iteritems(self.swagger_types): value = getattr(self, attr) if isinstance(value, list): result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, value.items() )) else: result[attr] = value return result def to_str(self): """ Returns the string representation of the model """ return pformat(self.to_dict()) def __repr__(self): """ For `print` and `pprint` """ return self.to_str() def __eq__(self, other): """ Returns true if both objects are equal """ if not isinstance(other, ConnectionDTO): return False return self.__dict__ == other.__dict__ def __ne__(self, other): """ Returns true if both objects are not equal """ return not self == other
import React from 'react'; import SmileIcon from './SmileIcon'; describe('Smile Icon', () => { it('renders without crash', () => { const smileIcon = shallow(<SmileIcon />); expect(smileIcon).toMatchSnapshot(); }); });
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fromStream = exports.fromBuffer = exports.EndOfStreamError = exports.fromFile = void 0; const fs = require("./FsPromise"); const core = require("./core"); var FileTokenizer_1 = require("./FileTokenizer"); Object.defineProperty(exports, "fromFile", { enumerable: true, get: function () { return FileTokenizer_1.fromFile; } }); var core_1 = require("./core"); Object.defineProperty(exports, "EndOfStreamError", { enumerable: true, get: function () { return core_1.EndOfStreamError; } }); Object.defineProperty(exports, "fromBuffer", { enumerable: true, get: function () { return core_1.fromBuffer; } }); /** * Construct ReadStreamTokenizer from given Stream. * Will set fileSize, if provided given Stream has set the .path property. * @param stream - Node.js Stream.Readable * @param fileInfo - Pass additional file information to the tokenizer * @returns Tokenizer */ async function fromStream(stream, fileInfo) { fileInfo = fileInfo ? fileInfo : {}; if (stream.path) { const stat = await fs.stat(stream.path); fileInfo.path = stream.path; fileInfo.size = stat.size; } return core.fromStream(stream, fileInfo); } exports.fromStream = fromStream;
import React from 'react'; import styled from 'styled-components'; const PageStyle = styled.div` background-color: #FF7600; padding:2em; width:90%; height:90%; margin: auto; `; export default PageStyle;
import React, { Component } from 'react'; import axios from 'axios'; import Modal from 'react-responsive-modal'; import Item from './Item'; import Upload from './Upload'; import Loader from 'react-loader-spinner'; import ReactPaginate from 'react-paginate'; import "react-loader-spinner/dist/loader/css/react-spinner-loader.css"; class Images extends Component { constructor(props) { super(props); this.state = { images: [], count: 0, loading: true, modal: false, uploaded: '', pageCount: 1, currentPage: 0, paginationLoading: false, lightBoxImages: [] } } handleModalOpen = () => { this.setState({modal: true}) } handleModalClose = () => { this.setState({modal: false}) } handleUploaded = (status) => { if(status === 'success') { return this.setState({loading: true}, () => { axios.get('/api/images').then(async ({data}) => { let pageCount = this.getPaginateRange(data.count); let lightBoxImages = await this.handleLightBoxImages(data.images); return this.setState({ images: data.images, pageCount, loading: false, modal: false, uploaded: status, lightBoxImages }); }) }); } this.setState({modal: false, uploaded: status}) } handlePageClick = (data) => { const { currentPage } = this.state; let offset = 9; if(data.selected > currentPage) { offset = offset * (currentPage + 1) } else { offset = offset * (currentPage - 1) } this.setState({ currentPage: data.selected, paginationLoading: true }, () => { axios.get(`/api/images/next/${offset}`).then(async (res) => { let lightBoxImages = await this.handleLightBoxImages(res.data.images); this.setState({ images: res.data.images, paginationLoading: false, lightBoxImages }); }) }) } getPaginateRange = (count) => { let counter = 0 for (let i = 9; i < count; i++) { if (i % 9 == 0) { counter++; } } return counter + 1; } handleLightBoxImages = async (images) => { let lightBoxImages = images.slice(); lightBoxImages = await lightBoxImages.map((image) => { return base_url + '/images/' + image.filename; }) return lightBoxImages; } componentDidMount() { axios.get('/api/images').then(async ({data}) => { let pageCount = this.getPaginateRange(data.count); let lightBoxImages = await this.handleLightBoxImages(data.images); this.setState({ images: data.images, count: data.count, pageCount, loading: false, lightBoxImages }); }).catch(exp => { console.log('exp: ', exp); this.setState({loading: false}); }) } render() { const { images, loading, modal, lightBoxImages } = this.state; return <div> <div className="row p-3 justify-content-end"> <button className="btn btn-outline-primary" onClick={this.handleModalOpen} > Upload Image </button> {modal && <Modal open={modal} onClose={this.handleModalClose} center> <Upload uploaded={this.handleUploaded} /> </Modal>} </div> {(loading) && <div className="row d-flex justify-content-center w-full nonagon-loader align-items-center"> <Loader type="Grid" color="#00BFFF" height={100} width={100} /> </div>} <div className="row"> {images.map((image, i) => <Item key={i} images={lightBoxImages} image={image} />)} {(!loading && !images.length) && <p className="not-found">No image found</p>} </div> {(!this.state.loading && (this.state.count > 9)) && <div className="row d-flex justify-content-center pl-3 pr-3 mb-2"> <nav aria-label="Image Pagination"> <ReactPaginate previousLabel={'previous'} nextLabel={'next'} breakLabel={'...'} breakClassName={'page-item'} breakLinkClassName={'page-link'} pageCount={this.state.pageCount} marginPagesDisplayed={2} pageRangeDisplayed={4} onPageChange={this.handlePageClick} previousClassName={'page-item'} nextClassName={'page-item'} previousLinkClassName={'page-link'} nextLinkClassName={'page-link'} pageClassName={'page-item'} pageLinkClassName={'page-link'} containerClassName={'pagination'} subContainerClassName={'pages pagination'} activeClassName={'active'} /> </nav> </div>} {/* <div className="row d-flex justify-content-center pl-3 pr-3 mb-2"> <nav aria-label="Image Pagination"> <ul className="pagination"> <li className="page-item disabled"><a className="page-link" href="#">Previous</a></li> <li className="page-item active"><a className="page-link" href="#">1</a></li> <li className="page-item"><a className="page-link" href="#">2</a></li> <li className="page-item"><a className="page-link" href="#">3</a></li> <li className="page-item"><a className="page-link" href="#">Next</a></li> </ul> </nav> </div> */} </div> } } export default Images;
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for tensorflow.ops.tf.Cholesky.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import unittest import numpy as np from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.compiler.tests import xla_test from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.ops import array_ops from tensorflow.python.ops import linalg_ops from tensorflow.python.ops import math_ops from tensorflow.python.platform import test class CholeskyOpTest(xla_test.XLATestCase): # Cholesky defined for float64, float32, complex64, complex128 # (https://www.tensorflow.org/api_docs/python/tf/cholesky) @property def float_types(self): return set(super(CholeskyOpTest, self).float_types).intersection( (np.float64, np.float32, np.complex64, np.complex128)) def _verifyCholeskyBase(self, sess, placeholder, x, chol, verification, atol): chol_np, verification_np = sess.run([chol, verification], {placeholder: x}) self.assertAllClose(x, verification_np, atol=atol) self.assertShapeEqual(x, chol) # Check that the cholesky is lower triangular, and has positive diagonal # elements. if chol_np.shape[-1] > 0: chol_reshaped = np.reshape(chol_np, (-1, chol_np.shape[-2], chol_np.shape[-1])) for chol_matrix in chol_reshaped: self.assertAllClose(chol_matrix, np.tril(chol_matrix), atol=atol) self.assertTrue((np.diag(chol_matrix) > 0.0).all()) def _verifyCholesky(self, x, atol=1e-6): # Verify that LL^T == x. with self.test_session() as sess: placeholder = array_ops.placeholder( dtypes.as_dtype(x.dtype), shape=x.shape) with self.test_scope(): chol = linalg_ops.cholesky(placeholder) verification = math_ops.matmul(chol, chol, adjoint_b=True) self._verifyCholeskyBase(sess, placeholder, x, chol, verification, atol) def testBasic(self): data = np.array([[4., -1., 2.], [-1., 6., 0], [2., 0., 5.]]) for dtype in self.float_types: self._verifyCholesky(data.astype(dtype)) def testBatch(self): for dtype in self.float_types: simple_array = np.array( [[[1., 0.], [0., 5.]]], dtype=dtype) # shape (1, 2, 2) self._verifyCholesky(simple_array) self._verifyCholesky(np.vstack((simple_array, simple_array))) odd_sized_array = np.array( [[[4., -1., 2.], [-1., 6., 0], [2., 0., 5.]]], dtype=dtype) self._verifyCholesky(np.vstack((odd_sized_array, odd_sized_array))) # Generate random positive-definite matrices. matrices = np.random.rand(10, 5, 5).astype(dtype) for i in xrange(10): matrices[i] = np.dot(matrices[i].T, matrices[i]) self._verifyCholesky(matrices, atol=1e-4) def testNonSquareMatrix(self): for dtype in self.float_types: with self.assertRaises(ValueError): linalg_ops.cholesky(np.array([[1., 2., 3.], [3., 4., 5.]], dtype=dtype)) with self.assertRaises(ValueError): linalg_ops.cholesky( np.array( [[[1., 2., 3.], [3., 4., 5.]], [[1., 2., 3.], [3., 4., 5.]]], dtype=dtype)) def testWrongDimensions(self): for dtype in self.float_types: tensor3 = constant_op.constant([1., 2.], dtype=dtype) with self.assertRaises(ValueError): linalg_ops.cholesky(tensor3) with self.assertRaises(ValueError): linalg_ops.cholesky(tensor3) @unittest.skip("Test is slow") def testLarge(self): n = 200 shape = (n, n) data = np.ones(shape).astype(np.float32) / (2.0 * n) + np.diag( np.ones(n).astype(np.float32)) self._verifyCholesky(data, atol=1e-4) def testMatrixConditionNumbers(self): for dtype in self.float_types: condition_number = 1000 size = 20 # Generate random positive-definite symmetric matrices, and take their # Eigendecomposition. matrix = np.random.rand(size, size) matrix = np.dot(matrix.T, matrix) _, w = np.linalg.eigh(matrix) # Build new Eigenvalues exponentially distributed between 1 and # 1/condition_number v = np.exp(-np.log(condition_number) * np.linspace(0, size, size) / size) matrix = np.dot(np.dot(w, np.diag(v)), w.T).astype(dtype) self._verifyCholesky(matrix, atol=1e-4) if __name__ == "__main__": test.main()
import "./data.json"; import mod1 from "./module1"; import mod2 from "./module2"; import { value1, value2 } from "./store"; it("should invalidate a self-accepted module", function(done) { expect(mod1).toBe(1); expect(mod2).toBe(1); expect(value1).toBe(1); expect(value2).toBe(1); let step = 0; module.hot.accept("./module1"); module.hot.accept("./module2"); module.hot.accept("./data.json", () => setTimeout(() => { switch (step) { case 0: step++; expect(mod1).toBe(1); expect(mod2).toBe(1); expect(value1).toBe(2); expect(value2).toBe(2); NEXT(require("../../update")(done)); break; case 1: step++; expect(mod1).toBe(2); expect(mod2).toBe(2); expect(value1).toBe(2); expect(value2).toBe(2); NEXT(require("../../update")(done)); break; case 2: step++; expect(mod1).toBe(3); expect(mod2).toBe(3); expect(value1).toBe(3); expect(value2).toBe(3); done(); break; default: done(new Error("should not happen")); break; } }, 100) ); NEXT(require("../../update")(done)); });
export function getFileTypeAndName(fileName) { let [ fileType, ...rest ] = decodeURIComponent(fileName).split('/'); console.log('file type name', fileType, rest); return { fileType, fileName: rest && rest.length ? rest.join('/') : '' }; }
/** * Created by vaibhav on 1/4/18 */ import React from 'react' import PropTypes from 'prop-types' import { TermsPageTemplate } from '../../templates/terms-page' const TermsPagePreview = ({ entry, getAsset }) => { const entryBlurbs = entry.getIn(['data', 'offerings', 'blurbs']) const blurbs = entryBlurbs ? entryBlurbs.toJS() : [] const entryColumns = entry.getIn(['data', 'twoColumn', 'columns']) const columns = entryColumns ? entryColumns.toJS() : [] const entryTestimonials = entry.getIn(['data', 'testimonials']) const testimonials = entryTestimonials ? entryTestimonials.toJS() : [] const entryContent = entry.getIn(['data', 'content']) const content = entryContent ? entryContent.toJS() : [] return ( <TermsPageTemplate title={entry.getIn(['data', 'title'])} meta_title={entry.getIn(['data', 'meta_title'])} meta_description={entry.getIn(['data', 'meta_description'])} heading={entry.getIn(['data', 'heading'])} description={entry.getIn(['data', 'description'])} offerings={{ blurbs }} twoColumn={{ columns }} content={content} testimonials={testimonials} /> ) } TermsPagePreview.propTypes = { entry: PropTypes.shape({ getIn: PropTypes.func, }), getAsset: PropTypes.func, } export default TermsPagePreview
const token = require('../../../auth/token') const responses = require('../../responses') const moment = require('moment') module.exports = { method: 'PATCH', path: '/token', handler: (request, reply) => { const payload = request.auth.credentials.token payload.exp = moment().add(1, 'hour').unix() return token.create(payload) .then((token) => reply(new responses.TokenCreated(token))) } }
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var React = require("react"); var Async_1 = require("./Async"); var EventGroup_1 = require("./EventGroup"); var warnConditionallyRequiredProps_1 = require("./warn/warnConditionallyRequiredProps"); var warnMutuallyExclusive_1 = require("./warn/warnMutuallyExclusive"); var warnDeprecations_1 = require("./warn/warnDeprecations"); /** * BaseComponent class, which provides basic helpers for all components. * * @public * {@docCategory BaseComponent} * * @deprecated Do not use. We are moving away from class component. */ var BaseComponent = /** @class */ (function (_super) { tslib_1.__extends(BaseComponent, _super); /** * BaseComponent constructor * @param props - The props for the component. * @param context - The context for the component. */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function BaseComponent(props, context) { var _this = _super.call(this, props, context) || this; // eslint-disable-next-line deprecation/deprecation _makeAllSafe(_this, BaseComponent.prototype, [ 'componentDidMount', 'shouldComponentUpdate', 'getSnapshotBeforeUpdate', 'render', 'componentDidUpdate', 'componentWillUnmount', ]); return _this; } /** * When the component receives props, make sure the componentRef is updated. */ BaseComponent.prototype.componentDidUpdate = function (prevProps, prevState) { this._updateComponentRef(prevProps, this.props); }; /** * When the component has mounted, update the componentRef. */ BaseComponent.prototype.componentDidMount = function () { this._setComponentRef(this.props.componentRef, this); }; /** * If we have disposables, dispose them automatically on unmount. */ BaseComponent.prototype.componentWillUnmount = function () { this._setComponentRef(this.props.componentRef, null); if (this.__disposables) { for (var i = 0, len = this._disposables.length; i < len; i++) { var disposable = this.__disposables[i]; if (disposable.dispose) { disposable.dispose(); } } this.__disposables = null; } }; Object.defineProperty(BaseComponent.prototype, "className", { /** * Gets the object's class name. */ get: function () { if (!this.__className) { var funcNameRegex = /function (.{1,})\(/; var results = funcNameRegex.exec(this.constructor.toString()); this.__className = results && results.length > 1 ? results[1] : ''; } return this.__className; }, enumerable: true, configurable: true }); Object.defineProperty(BaseComponent.prototype, "_disposables", { /** * Allows subclasses to push things to this._disposables to be auto disposed. */ get: function () { if (!this.__disposables) { this.__disposables = []; } return this.__disposables; }, enumerable: true, configurable: true }); Object.defineProperty(BaseComponent.prototype, "_async", { /** * Gets the async instance associated with the component, created on demand. The async instance gives * subclasses a way to execute setTimeout/setInterval async calls safely, where the callbacks * will be cleared/ignored automatically after unmounting. The helpers within the async object also * preserve the this pointer so that you don't need to "bind" the callbacks. */ get: function () { if (!this.__async) { this.__async = new Async_1.Async(this); this._disposables.push(this.__async); } return this.__async; }, enumerable: true, configurable: true }); Object.defineProperty(BaseComponent.prototype, "_events", { /** * Gets the event group instance assocaited with the component, created on demand. The event instance * provides on/off methods for listening to DOM (or regular javascript object) events. The event callbacks * will be automatically disconnected after unmounting. The helpers within the events object also * preserve the this reference so that you don't need to "bind" the callbacks. */ get: function () { if (!this.__events) { this.__events = new EventGroup_1.EventGroup(this); this._disposables.push(this.__events); } return this.__events; }, enumerable: true, configurable: true }); /** * Helper to return a memoized ref resolver function. * @param refName - Name of the member to assign the ref to. * @returns A function instance keyed from the given refname. * @deprecated Use `createRef` from React.createRef. */ BaseComponent.prototype._resolveRef = function (refName) { var _this = this; if (!this.__resolves) { this.__resolves = {}; } if (!this.__resolves[refName]) { this.__resolves[refName] = function (ref) { // eslint-disable-next-line @typescript-eslint/no-explicit-any return (_this[refName] = ref); }; } return this.__resolves[refName]; }; /** * Updates the componentRef (by calling it with "this" when necessary.) */ BaseComponent.prototype._updateComponentRef = function (currentProps, newProps) { if (newProps === void 0) { newProps = {}; } // currentProps *should* always be defined, but verify that just in case a subclass is manually // calling a lifecycle method with no parameters (which has happened) or other odd usage. if (currentProps && newProps && currentProps.componentRef !== newProps.componentRef) { this._setComponentRef(currentProps.componentRef, null); this._setComponentRef(newProps.componentRef, this); } }; /** * Warns when a deprecated props are being used. * * @param deprecationMap - The map of deprecations, where key is the prop name and the value is * either null or a replacement prop name. */ BaseComponent.prototype._warnDeprecations = function (deprecationMap) { warnDeprecations_1.warnDeprecations(this.className, this.props, deprecationMap); }; /** * Warns when props which are mutually exclusive with each other are both used. * * @param mutuallyExclusiveMap - The map of mutually exclusive props. */ BaseComponent.prototype._warnMutuallyExclusive = function (mutuallyExclusiveMap) { warnMutuallyExclusive_1.warnMutuallyExclusive(this.className, this.props, mutuallyExclusiveMap); }; /** * Warns when props are required if a condition is met. * * @param requiredProps - The name of the props that are required when the condition is met. * @param conditionalPropName - The name of the prop that the condition is based on. * @param condition - Whether the condition is met. */ BaseComponent.prototype._warnConditionallyRequiredProps = function (requiredProps, conditionalPropName, condition) { warnConditionallyRequiredProps_1.warnConditionallyRequiredProps(this.className, this.props, requiredProps, conditionalPropName, condition); }; BaseComponent.prototype._setComponentRef = function (ref, value) { if (!this._skipComponentRefResolution && ref) { if (typeof ref === 'function') { ref(value); } if (typeof ref === 'object') { // eslint-disable-next-line @typescript-eslint/no-explicit-any ref.current = value; } } }; return BaseComponent; }(React.Component)); exports.BaseComponent = BaseComponent; /** * Helper to override a given method with a wrapper method that can try/catch the original, but also * ensures that the BaseComponent's methods are called before the subclass's. This ensures that * componentWillUnmount in the base is called and that things in the _disposables array are disposed. */ // eslint-disable-next-line deprecation/deprecation function _makeAllSafe(obj, prototype, methodNames) { for (var i = 0, len = methodNames.length; i < len; i++) { _makeSafe(obj, prototype, methodNames[i]); } } // eslint-disable-next-line deprecation/deprecation function _makeSafe(obj, prototype, methodName) { /* eslint-disable @typescript-eslint/no-explicit-any */ var classMethod = obj[methodName]; var prototypeMethod = prototype[methodName]; if (classMethod || prototypeMethod) { obj[methodName] = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } /* eslint-enable @typescript-eslint/no-explicit-any */ var retVal; if (prototypeMethod) { retVal = prototypeMethod.apply(this, args); } if (classMethod !== prototypeMethod) { retVal = classMethod.apply(this, args); } return retVal; }; } } /** * Simple constant function for returning null, used to render empty templates in JSX. * * @public */ function nullRender() { return null; } exports.nullRender = nullRender; //# sourceMappingURL=BaseComponent.js.map
(function(scope){ 'use strict'; function F(arity, fun, wrapper) { wrapper.a = arity; wrapper.f = fun; return wrapper; } function F2(fun) { return F(2, fun, function(a) { return function(b) { return fun(a,b); }; }) } function F3(fun) { return F(3, fun, function(a) { return function(b) { return function(c) { return fun(a, b, c); }; }; }); } function F4(fun) { return F(4, fun, function(a) { return function(b) { return function(c) { return function(d) { return fun(a, b, c, d); }; }; }; }); } function F5(fun) { return F(5, fun, function(a) { return function(b) { return function(c) { return function(d) { return function(e) { return fun(a, b, c, d, e); }; }; }; }; }); } function F6(fun) { return F(6, fun, function(a) { return function(b) { return function(c) { return function(d) { return function(e) { return function(f) { return fun(a, b, c, d, e, f); }; }; }; }; }; }); } function F7(fun) { return F(7, fun, function(a) { return function(b) { return function(c) { return function(d) { return function(e) { return function(f) { return function(g) { return fun(a, b, c, d, e, f, g); }; }; }; }; }; }; }); } function F8(fun) { return F(8, fun, function(a) { return function(b) { return function(c) { return function(d) { return function(e) { return function(f) { return function(g) { return function(h) { return fun(a, b, c, d, e, f, g, h); }; }; }; }; }; }; }; }); } function F9(fun) { return F(9, fun, function(a) { return function(b) { return function(c) { return function(d) { return function(e) { return function(f) { return function(g) { return function(h) { return function(i) { return fun(a, b, c, d, e, f, g, h, i); }; }; }; }; }; }; }; }; }); } function A2(fun, a, b) { return fun.a === 2 ? fun.f(a, b) : fun(a)(b); } function A3(fun, a, b, c) { return fun.a === 3 ? fun.f(a, b, c) : fun(a)(b)(c); } function A4(fun, a, b, c, d) { return fun.a === 4 ? fun.f(a, b, c, d) : fun(a)(b)(c)(d); } function A5(fun, a, b, c, d, e) { return fun.a === 5 ? fun.f(a, b, c, d, e) : fun(a)(b)(c)(d)(e); } function A6(fun, a, b, c, d, e, f) { return fun.a === 6 ? fun.f(a, b, c, d, e, f) : fun(a)(b)(c)(d)(e)(f); } function A7(fun, a, b, c, d, e, f, g) { return fun.a === 7 ? fun.f(a, b, c, d, e, f, g) : fun(a)(b)(c)(d)(e)(f)(g); } function A8(fun, a, b, c, d, e, f, g, h) { return fun.a === 8 ? fun.f(a, b, c, d, e, f, g, h) : fun(a)(b)(c)(d)(e)(f)(g)(h); } function A9(fun, a, b, c, d, e, f, g, h, i) { return fun.a === 9 ? fun.f(a, b, c, d, e, f, g, h, i) : fun(a)(b)(c)(d)(e)(f)(g)(h)(i); } console.warn('Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.0/optimize for better performance and smaller assets.'); var _JsArray_empty = []; function _JsArray_singleton(value) { return [value]; } function _JsArray_length(array) { return array.length; } var _JsArray_initialize = F3(function(size, offset, func) { var result = new Array(size); for (var i = 0; i < size; i++) { result[i] = func(offset + i); } return result; }); var _JsArray_initializeFromList = F2(function (max, ls) { var result = new Array(max); for (var i = 0; i < max && ls.b; i++) { result[i] = ls.a; ls = ls.b; } result.length = i; return _Utils_Tuple2(result, ls); }); var _JsArray_unsafeGet = F2(function(index, array) { return array[index]; }); var _JsArray_unsafeSet = F3(function(index, value, array) { var length = array.length; var result = new Array(length); for (var i = 0; i < length; i++) { result[i] = array[i]; } result[index] = value; return result; }); var _JsArray_push = F2(function(value, array) { var length = array.length; var result = new Array(length + 1); for (var i = 0; i < length; i++) { result[i] = array[i]; } result[length] = value; return result; }); var _JsArray_foldl = F3(function(func, acc, array) { var length = array.length; for (var i = 0; i < length; i++) { acc = A2(func, array[i], acc); } return acc; }); var _JsArray_foldr = F3(function(func, acc, array) { for (var i = array.length - 1; i >= 0; i--) { acc = A2(func, array[i], acc); } return acc; }); var _JsArray_map = F2(function(func, array) { var length = array.length; var result = new Array(length); for (var i = 0; i < length; i++) { result[i] = func(array[i]); } return result; }); var _JsArray_indexedMap = F3(function(func, offset, array) { var length = array.length; var result = new Array(length); for (var i = 0; i < length; i++) { result[i] = A2(func, offset + i, array[i]); } return result; }); var _JsArray_slice = F3(function(from, to, array) { return array.slice(from, to); }); var _JsArray_appendN = F3(function(n, dest, source) { var destLen = dest.length; var itemsToCopy = n - destLen; if (itemsToCopy > source.length) { itemsToCopy = source.length; } var size = destLen + itemsToCopy; var result = new Array(size); for (var i = 0; i < destLen; i++) { result[i] = dest[i]; } for (var i = 0; i < itemsToCopy; i++) { result[i + destLen] = source[i]; } return result; }); // LOG var _Debug_log_UNUSED = F2(function(tag, value) { return value; }); var _Debug_log = F2(function(tag, value) { console.log(tag + ': ' + _Debug_toString(value)); return value; }); // TODOS function _Debug_todo(moduleName, region) { return function(message) { _Debug_crash(8, moduleName, region, message); }; } function _Debug_todoCase(moduleName, region, value) { return function(message) { _Debug_crash(9, moduleName, region, value, message); }; } // TO STRING function _Debug_toString_UNUSED(value) { return '<internals>'; } function _Debug_toString(value) { return _Debug_toAnsiString(false, value); } function _Debug_toAnsiString(ansi, value) { if (typeof value === 'function') { return _Debug_internalColor(ansi, '<function>'); } if (typeof value === 'boolean') { return _Debug_ctorColor(ansi, value ? 'True' : 'False'); } if (typeof value === 'number') { return _Debug_numberColor(ansi, value + ''); } if (value instanceof String) { return _Debug_charColor(ansi, "'" + _Debug_addSlashes(value, true) + "'"); } if (typeof value === 'string') { return _Debug_stringColor(ansi, '"' + _Debug_addSlashes(value, false) + '"'); } if (typeof value === 'object' && '$' in value) { var tag = value.$; if (typeof tag === 'number') { return _Debug_internalColor(ansi, '<internals>'); } if (tag[0] === '#') { var output = []; for (var k in value) { if (k === '$') continue; output.push(_Debug_toAnsiString(ansi, value[k])); } return '(' + output.join(',') + ')'; } if (tag === 'Set_elm_builtin') { return _Debug_ctorColor(ansi, 'Set') + _Debug_fadeColor(ansi, '.fromList') + ' ' + _Debug_toAnsiString(ansi, elm$core$Set$toList(value)); } if (tag === 'RBNode_elm_builtin' || tag === 'RBEmpty_elm_builtin') { return _Debug_ctorColor(ansi, 'Dict') + _Debug_fadeColor(ansi, '.fromList') + ' ' + _Debug_toAnsiString(ansi, elm$core$Dict$toList(value)); } if (tag === 'Array_elm_builtin') { return _Debug_ctorColor(ansi, 'Array') + _Debug_fadeColor(ansi, '.fromList') + ' ' + _Debug_toAnsiString(ansi, elm$core$Array$toList(value)); } if (tag === '::' || tag === '[]') { var output = '['; value.b && (output += _Debug_toAnsiString(ansi, value.a), value = value.b) for (; value.b; value = value.b) // WHILE_CONS { output += ',' + _Debug_toAnsiString(ansi, value.a); } return output + ']'; } var output = ''; for (var i in value) { if (i === '$') continue; var str = _Debug_toAnsiString(ansi, value[i]); var c0 = str[0]; var parenless = c0 === '{' || c0 === '(' || c0 === '[' || c0 === '<' || c0 === '"' || str.indexOf(' ') < 0; output += ' ' + (parenless ? str : '(' + str + ')'); } return _Debug_ctorColor(ansi, tag) + output; } if (typeof DataView === 'function' && value instanceof DataView) { return _Debug_stringColor(ansi, '<' + value.byteLength + ' bytes>'); } if (typeof File === 'function' && value instanceof File) { return _Debug_internalColor(ansi, '<' + value.name + '>'); } if (typeof value === 'object') { var output = []; for (var key in value) { var field = key[0] === '_' ? key.slice(1) : key; output.push(_Debug_fadeColor(ansi, field) + ' = ' + _Debug_toAnsiString(ansi, value[key])); } if (output.length === 0) { return '{}'; } return '{ ' + output.join(', ') + ' }'; } return _Debug_internalColor(ansi, '<internals>'); } function _Debug_addSlashes(str, isChar) { var s = str .replace(/\\/g, '\\\\') .replace(/\n/g, '\\n') .replace(/\t/g, '\\t') .replace(/\r/g, '\\r') .replace(/\v/g, '\\v') .replace(/\0/g, '\\0'); if (isChar) { return s.replace(/\'/g, '\\\''); } else { return s.replace(/\"/g, '\\"'); } } function _Debug_ctorColor(ansi, string) { return ansi ? '\x1b[96m' + string + '\x1b[0m' : string; } function _Debug_numberColor(ansi, string) { return ansi ? '\x1b[95m' + string + '\x1b[0m' : string; } function _Debug_stringColor(ansi, string) { return ansi ? '\x1b[93m' + string + '\x1b[0m' : string; } function _Debug_charColor(ansi, string) { return ansi ? '\x1b[92m' + string + '\x1b[0m' : string; } function _Debug_fadeColor(ansi, string) { return ansi ? '\x1b[37m' + string + '\x1b[0m' : string; } function _Debug_internalColor(ansi, string) { return ansi ? '\x1b[94m' + string + '\x1b[0m' : string; } function _Debug_toHexDigit(n) { return String.fromCharCode(n < 10 ? 48 + n : 55 + n); } // CRASH function _Debug_crash_UNUSED(identifier) { throw new Error('https://github.com/elm/core/blob/1.0.0/hints/' + identifier + '.md'); } function _Debug_crash(identifier, fact1, fact2, fact3, fact4) { switch(identifier) { case 0: throw new Error('What node should I take over? In JavaScript I need something like:\n\n Elm.Main.init({\n node: document.getElementById("elm-node")\n })\n\nYou need to do this with any Browser.sandbox or Browser.element program.'); case 1: throw new Error('Browser.application programs cannot handle URLs like this:\n\n ' + document.location.href + '\n\nWhat is the root? The root of your file system? Try looking at this program with `elm reactor` or some other server.'); case 2: var jsonErrorString = fact1; throw new Error('Problem with the flags given to your Elm program on initialization.\n\n' + jsonErrorString); case 3: var portName = fact1; throw new Error('There can only be one port named `' + portName + '`, but your program has multiple.'); case 4: var portName = fact1; var problem = fact2; throw new Error('Trying to send an unexpected type of value through port `' + portName + '`:\n' + problem); case 5: throw new Error('Trying to use `(==)` on functions.\nThere is no way to know if functions are "the same" in the Elm sense.\nRead more about this at https://package.elm-lang.org/packages/elm/core/latest/Basics#== which describes why it is this way and what the better version will look like.'); case 6: var moduleName = fact1; throw new Error('Your page is loading multiple Elm scripts with a module named ' + moduleName + '. Maybe a duplicate script is getting loaded accidentally? If not, rename one of them so I know which is which!'); case 8: var moduleName = fact1; var region = fact2; var message = fact3; throw new Error('TODO in module `' + moduleName + '` ' + _Debug_regionToString(region) + '\n\n' + message); case 9: var moduleName = fact1; var region = fact2; var value = fact3; var message = fact4; throw new Error( 'TODO in module `' + moduleName + '` from the `case` expression ' + _Debug_regionToString(region) + '\n\nIt received the following value:\n\n ' + _Debug_toString(value).replace('\n', '\n ') + '\n\nBut the branch that handles it says:\n\n ' + message.replace('\n', '\n ') ); case 10: throw new Error('Bug in https://github.com/elm/virtual-dom/issues'); case 11: throw new Error('Cannot perform mod 0. Division by zero error.'); } } function _Debug_regionToString(region) { if (region.start.line === region.end.line) { return 'on line ' + region.start.line; } return 'on lines ' + region.start.line + ' through ' + region.end.line; } // EQUALITY function _Utils_eq(x, y) { for ( var pair, stack = [], isEqual = _Utils_eqHelp(x, y, 0, stack); isEqual && (pair = stack.pop()); isEqual = _Utils_eqHelp(pair.a, pair.b, 0, stack) ) {} return isEqual; } function _Utils_eqHelp(x, y, depth, stack) { if (depth > 100) { stack.push(_Utils_Tuple2(x,y)); return true; } if (x === y) { return true; } if (typeof x !== 'object' || x === null || y === null) { typeof x === 'function' && _Debug_crash(5); return false; } /**/ if (x.$ === 'Set_elm_builtin') { x = elm$core$Set$toList(x); y = elm$core$Set$toList(y); } if (x.$ === 'RBNode_elm_builtin' || x.$ === 'RBEmpty_elm_builtin') { x = elm$core$Dict$toList(x); y = elm$core$Dict$toList(y); } //*/ /**_UNUSED/ if (x.$ < 0) { x = elm$core$Dict$toList(x); y = elm$core$Dict$toList(y); } //*/ for (var key in x) { if (!_Utils_eqHelp(x[key], y[key], depth + 1, stack)) { return false; } } return true; } var _Utils_equal = F2(_Utils_eq); var _Utils_notEqual = F2(function(a, b) { return !_Utils_eq(a,b); }); // COMPARISONS // Code in Generate/JavaScript.hs, Basics.js, and List.js depends on // the particular integer values assigned to LT, EQ, and GT. function _Utils_cmp(x, y, ord) { if (typeof x !== 'object') { return x === y ? /*EQ*/ 0 : x < y ? /*LT*/ -1 : /*GT*/ 1; } /**/ if (x instanceof String) { var a = x.valueOf(); var b = y.valueOf(); return a === b ? 0 : a < b ? -1 : 1; } //*/ /**_UNUSED/ if (typeof x.$ === 'undefined') //*/ /**/ if (x.$[0] === '#') //*/ { return (ord = _Utils_cmp(x.a, y.a)) ? ord : (ord = _Utils_cmp(x.b, y.b)) ? ord : _Utils_cmp(x.c, y.c); } // traverse conses until end of a list or a mismatch for (; x.b && y.b && !(ord = _Utils_cmp(x.a, y.a)); x = x.b, y = y.b) {} // WHILE_CONSES return ord || (x.b ? /*GT*/ 1 : y.b ? /*LT*/ -1 : /*EQ*/ 0); } var _Utils_lt = F2(function(a, b) { return _Utils_cmp(a, b) < 0; }); var _Utils_le = F2(function(a, b) { return _Utils_cmp(a, b) < 1; }); var _Utils_gt = F2(function(a, b) { return _Utils_cmp(a, b) > 0; }); var _Utils_ge = F2(function(a, b) { return _Utils_cmp(a, b) >= 0; }); var _Utils_compare = F2(function(x, y) { var n = _Utils_cmp(x, y); return n < 0 ? elm$core$Basics$LT : n ? elm$core$Basics$GT : elm$core$Basics$EQ; }); // COMMON VALUES var _Utils_Tuple0_UNUSED = 0; var _Utils_Tuple0 = { $: '#0' }; function _Utils_Tuple2_UNUSED(a, b) { return { a: a, b: b }; } function _Utils_Tuple2(a, b) { return { $: '#2', a: a, b: b }; } function _Utils_Tuple3_UNUSED(a, b, c) { return { a: a, b: b, c: c }; } function _Utils_Tuple3(a, b, c) { return { $: '#3', a: a, b: b, c: c }; } function _Utils_chr_UNUSED(c) { return c; } function _Utils_chr(c) { return new String(c); } // RECORDS function _Utils_update(oldRecord, updatedFields) { var newRecord = {}; for (var key in oldRecord) { newRecord[key] = oldRecord[key]; } for (var key in updatedFields) { newRecord[key] = updatedFields[key]; } return newRecord; } // APPEND var _Utils_append = F2(_Utils_ap); function _Utils_ap(xs, ys) { // append Strings if (typeof xs === 'string') { return xs + ys; } // append Lists if (!xs.b) { return ys; } var root = _List_Cons(xs.a, ys); xs = xs.b for (var curr = root; xs.b; xs = xs.b) // WHILE_CONS { curr = curr.b = _List_Cons(xs.a, ys); } return root; } var _List_Nil_UNUSED = { $: 0 }; var _List_Nil = { $: '[]' }; function _List_Cons_UNUSED(hd, tl) { return { $: 1, a: hd, b: tl }; } function _List_Cons(hd, tl) { return { $: '::', a: hd, b: tl }; } var _List_cons = F2(_List_Cons); function _List_fromArray(arr) { var out = _List_Nil; for (var i = arr.length; i--; ) { out = _List_Cons(arr[i], out); } return out; } function _List_toArray(xs) { for (var out = []; xs.b; xs = xs.b) // WHILE_CONS { out.push(xs.a); } return out; } var _List_map2 = F3(function(f, xs, ys) { for (var arr = []; xs.b && ys.b; xs = xs.b, ys = ys.b) // WHILE_CONSES { arr.push(A2(f, xs.a, ys.a)); } return _List_fromArray(arr); }); var _List_map3 = F4(function(f, xs, ys, zs) { for (var arr = []; xs.b && ys.b && zs.b; xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES { arr.push(A3(f, xs.a, ys.a, zs.a)); } return _List_fromArray(arr); }); var _List_map4 = F5(function(f, ws, xs, ys, zs) { for (var arr = []; ws.b && xs.b && ys.b && zs.b; ws = ws.b, xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES { arr.push(A4(f, ws.a, xs.a, ys.a, zs.a)); } return _List_fromArray(arr); }); var _List_map5 = F6(function(f, vs, ws, xs, ys, zs) { for (var arr = []; vs.b && ws.b && xs.b && ys.b && zs.b; vs = vs.b, ws = ws.b, xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES { arr.push(A5(f, vs.a, ws.a, xs.a, ys.a, zs.a)); } return _List_fromArray(arr); }); var _List_sortBy = F2(function(f, xs) { return _List_fromArray(_List_toArray(xs).sort(function(a, b) { return _Utils_cmp(f(a), f(b)); })); }); var _List_sortWith = F2(function(f, xs) { return _List_fromArray(_List_toArray(xs).sort(function(a, b) { var ord = A2(f, a, b); return ord === elm$core$Basics$EQ ? 0 : ord === elm$core$Basics$LT ? -1 : 1; })); }); // MATH var _Basics_add = F2(function(a, b) { return a + b; }); var _Basics_sub = F2(function(a, b) { return a - b; }); var _Basics_mul = F2(function(a, b) { return a * b; }); var _Basics_fdiv = F2(function(a, b) { return a / b; }); var _Basics_idiv = F2(function(a, b) { return (a / b) | 0; }); var _Basics_pow = F2(Math.pow); var _Basics_remainderBy = F2(function(b, a) { return a % b; }); // https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/divmodnote-letter.pdf var _Basics_modBy = F2(function(modulus, x) { var answer = x % modulus; return modulus === 0 ? _Debug_crash(11) : ((answer > 0 && modulus < 0) || (answer < 0 && modulus > 0)) ? answer + modulus : answer; }); // TRIGONOMETRY var _Basics_pi = Math.PI; var _Basics_e = Math.E; var _Basics_cos = Math.cos; var _Basics_sin = Math.sin; var _Basics_tan = Math.tan; var _Basics_acos = Math.acos; var _Basics_asin = Math.asin; var _Basics_atan = Math.atan; var _Basics_atan2 = F2(Math.atan2); // MORE MATH function _Basics_toFloat(x) { return x; } function _Basics_truncate(n) { return n | 0; } function _Basics_isInfinite(n) { return n === Infinity || n === -Infinity; } var _Basics_ceiling = Math.ceil; var _Basics_floor = Math.floor; var _Basics_round = Math.round; var _Basics_sqrt = Math.sqrt; var _Basics_log = Math.log; var _Basics_isNaN = isNaN; // BOOLEANS function _Basics_not(bool) { return !bool; } var _Basics_and = F2(function(a, b) { return a && b; }); var _Basics_or = F2(function(a, b) { return a || b; }); var _Basics_xor = F2(function(a, b) { return a !== b; }); function _Char_toCode(char) { var code = char.charCodeAt(0); if (0xD800 <= code && code <= 0xDBFF) { return (code - 0xD800) * 0x400 + char.charCodeAt(1) - 0xDC00 + 0x10000 } return code; } function _Char_fromCode(code) { return _Utils_chr( (code < 0 || 0x10FFFF < code) ? '\uFFFD' : (code <= 0xFFFF) ? String.fromCharCode(code) : (code -= 0x10000, String.fromCharCode(Math.floor(code / 0x400) + 0xD800, code % 0x400 + 0xDC00) ) ); } function _Char_toUpper(char) { return _Utils_chr(char.toUpperCase()); } function _Char_toLower(char) { return _Utils_chr(char.toLowerCase()); } function _Char_toLocaleUpper(char) { return _Utils_chr(char.toLocaleUpperCase()); } function _Char_toLocaleLower(char) { return _Utils_chr(char.toLocaleLowerCase()); } var _String_cons = F2(function(chr, str) { return chr + str; }); function _String_uncons(string) { var word = string.charCodeAt(0); return word ? elm$core$Maybe$Just( 0xD800 <= word && word <= 0xDBFF ? _Utils_Tuple2(_Utils_chr(string[0] + string[1]), string.slice(2)) : _Utils_Tuple2(_Utils_chr(string[0]), string.slice(1)) ) : elm$core$Maybe$Nothing; } var _String_append = F2(function(a, b) { return a + b; }); function _String_length(str) { return str.length; } var _String_map = F2(function(func, string) { var len = string.length; var array = new Array(len); var i = 0; while (i < len) { var word = string.charCodeAt(i); if (0xD800 <= word && word <= 0xDBFF) { array[i] = func(_Utils_chr(string[i] + string[i+1])); i += 2; continue; } array[i] = func(_Utils_chr(string[i])); i++; } return array.join(''); }); var _String_filter = F2(function(isGood, str) { var arr = []; var len = str.length; var i = 0; while (i < len) { var char = str[i]; var word = str.charCodeAt(i); i++; if (0xD800 <= word && word <= 0xDBFF) { char += str[i]; i++; } if (isGood(_Utils_chr(char))) { arr.push(char); } } return arr.join(''); }); function _String_reverse(str) { var len = str.length; var arr = new Array(len); var i = 0; while (i < len) { var word = str.charCodeAt(i); if (0xD800 <= word && word <= 0xDBFF) { arr[len - i] = str[i + 1]; i++; arr[len - i] = str[i - 1]; i++; } else { arr[len - i] = str[i]; i++; } } return arr.join(''); } var _String_foldl = F3(function(func, state, string) { var len = string.length; var i = 0; while (i < len) { var char = string[i]; var word = string.charCodeAt(i); i++; if (0xD800 <= word && word <= 0xDBFF) { char += string[i]; i++; } state = A2(func, _Utils_chr(char), state); } return state; }); var _String_foldr = F3(function(func, state, string) { var i = string.length; while (i--) { var char = string[i]; var word = string.charCodeAt(i); if (0xDC00 <= word && word <= 0xDFFF) { i--; char = string[i] + char; } state = A2(func, _Utils_chr(char), state); } return state; }); var _String_split = F2(function(sep, str) { return str.split(sep); }); var _String_join = F2(function(sep, strs) { return strs.join(sep); }); var _String_slice = F3(function(start, end, str) { return str.slice(start, end); }); function _String_trim(str) { return str.trim(); } function _String_trimLeft(str) { return str.replace(/^\s+/, ''); } function _String_trimRight(str) { return str.replace(/\s+$/, ''); } function _String_words(str) { return _List_fromArray(str.trim().split(/\s+/g)); } function _String_lines(str) { return _List_fromArray(str.split(/\r\n|\r|\n/g)); } function _String_toUpper(str) { return str.toUpperCase(); } function _String_toLower(str) { return str.toLowerCase(); } var _String_any = F2(function(isGood, string) { var i = string.length; while (i--) { var char = string[i]; var word = string.charCodeAt(i); if (0xDC00 <= word && word <= 0xDFFF) { i--; char = string[i] + char; } if (isGood(_Utils_chr(char))) { return true; } } return false; }); var _String_all = F2(function(isGood, string) { var i = string.length; while (i--) { var char = string[i]; var word = string.charCodeAt(i); if (0xDC00 <= word && word <= 0xDFFF) { i--; char = string[i] + char; } if (!isGood(_Utils_chr(char))) { return false; } } return true; }); var _String_contains = F2(function(sub, str) { return str.indexOf(sub) > -1; }); var _String_startsWith = F2(function(sub, str) { return str.indexOf(sub) === 0; }); var _String_endsWith = F2(function(sub, str) { return str.length >= sub.length && str.lastIndexOf(sub) === str.length - sub.length; }); var _String_indexes = F2(function(sub, str) { var subLen = sub.length; if (subLen < 1) { return _List_Nil; } var i = 0; var is = []; while ((i = str.indexOf(sub, i)) > -1) { is.push(i); i = i + subLen; } return _List_fromArray(is); }); // TO STRING function _String_fromNumber(number) { return number + ''; } // INT CONVERSIONS function _String_toInt(str) { var total = 0; var code0 = str.charCodeAt(0); var start = code0 == 0x2B /* + */ || code0 == 0x2D /* - */ ? 1 : 0; for (var i = start; i < str.length; ++i) { var code = str.charCodeAt(i); if (code < 0x30 || 0x39 < code) { return elm$core$Maybe$Nothing; } total = 10 * total + code - 0x30; } return i == start ? elm$core$Maybe$Nothing : elm$core$Maybe$Just(code0 == 0x2D ? -total : total); } // FLOAT CONVERSIONS function _String_toFloat(s) { // check if it is a hex, octal, or binary number if (s.length === 0 || /[\sxbo]/.test(s)) { return elm$core$Maybe$Nothing; } var n = +s; // faster isNaN check return n === n ? elm$core$Maybe$Just(n) : elm$core$Maybe$Nothing; } function _String_fromList(chars) { return _List_toArray(chars).join(''); } /**/ function _Json_errorToString(error) { return elm$json$Json$Decode$errorToString(error); } //*/ // CORE DECODERS function _Json_succeed(msg) { return { $: 0, a: msg }; } function _Json_fail(msg) { return { $: 1, a: msg }; } function _Json_decodePrim(decoder) { return { $: 2, b: decoder }; } var _Json_decodeInt = _Json_decodePrim(function(value) { return (typeof value !== 'number') ? _Json_expecting('an INT', value) : (-2147483647 < value && value < 2147483647 && (value | 0) === value) ? elm$core$Result$Ok(value) : (isFinite(value) && !(value % 1)) ? elm$core$Result$Ok(value) : _Json_expecting('an INT', value); }); var _Json_decodeBool = _Json_decodePrim(function(value) { return (typeof value === 'boolean') ? elm$core$Result$Ok(value) : _Json_expecting('a BOOL', value); }); var _Json_decodeFloat = _Json_decodePrim(function(value) { return (typeof value === 'number') ? elm$core$Result$Ok(value) : _Json_expecting('a FLOAT', value); }); var _Json_decodeValue = _Json_decodePrim(function(value) { return elm$core$Result$Ok(_Json_wrap(value)); }); var _Json_decodeString = _Json_decodePrim(function(value) { return (typeof value === 'string') ? elm$core$Result$Ok(value) : (value instanceof String) ? elm$core$Result$Ok(value + '') : _Json_expecting('a STRING', value); }); function _Json_decodeList(decoder) { return { $: 3, b: decoder }; } function _Json_decodeArray(decoder) { return { $: 4, b: decoder }; } function _Json_decodeNull(value) { return { $: 5, c: value }; } var _Json_decodeField = F2(function(field, decoder) { return { $: 6, d: field, b: decoder }; }); var _Json_decodeIndex = F2(function(index, decoder) { return { $: 7, e: index, b: decoder }; }); function _Json_decodeKeyValuePairs(decoder) { return { $: 8, b: decoder }; } function _Json_mapMany(f, decoders) { return { $: 9, f: f, g: decoders }; } var _Json_andThen = F2(function(callback, decoder) { return { $: 10, b: decoder, h: callback }; }); function _Json_oneOf(decoders) { return { $: 11, g: decoders }; } // DECODING OBJECTS var _Json_map1 = F2(function(f, d1) { return _Json_mapMany(f, [d1]); }); var _Json_map2 = F3(function(f, d1, d2) { return _Json_mapMany(f, [d1, d2]); }); var _Json_map3 = F4(function(f, d1, d2, d3) { return _Json_mapMany(f, [d1, d2, d3]); }); var _Json_map4 = F5(function(f, d1, d2, d3, d4) { return _Json_mapMany(f, [d1, d2, d3, d4]); }); var _Json_map5 = F6(function(f, d1, d2, d3, d4, d5) { return _Json_mapMany(f, [d1, d2, d3, d4, d5]); }); var _Json_map6 = F7(function(f, d1, d2, d3, d4, d5, d6) { return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6]); }); var _Json_map7 = F8(function(f, d1, d2, d3, d4, d5, d6, d7) { return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7]); }); var _Json_map8 = F9(function(f, d1, d2, d3, d4, d5, d6, d7, d8) { return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7, d8]); }); // DECODE var _Json_runOnString = F2(function(decoder, string) { try { var value = JSON.parse(string); return _Json_runHelp(decoder, value); } catch (e) { return elm$core$Result$Err(A2(elm$json$Json$Decode$Failure, 'This is not valid JSON! ' + e.message, _Json_wrap(string))); } }); var _Json_run = F2(function(decoder, value) { return _Json_runHelp(decoder, _Json_unwrap(value)); }); function _Json_runHelp(decoder, value) { switch (decoder.$) { case 2: return decoder.b(value); case 5: return (value === null) ? elm$core$Result$Ok(decoder.c) : _Json_expecting('null', value); case 3: if (!_Json_isArray(value)) { return _Json_expecting('a LIST', value); } return _Json_runArrayDecoder(decoder.b, value, _List_fromArray); case 4: if (!_Json_isArray(value)) { return _Json_expecting('an ARRAY', value); } return _Json_runArrayDecoder(decoder.b, value, _Json_toElmArray); case 6: var field = decoder.d; if (typeof value !== 'object' || value === null || !(field in value)) { return _Json_expecting('an OBJECT with a field named `' + field + '`', value); } var result = _Json_runHelp(decoder.b, value[field]); return (elm$core$Result$isOk(result)) ? result : elm$core$Result$Err(A2(elm$json$Json$Decode$Field, field, result.a)); case 7: var index = decoder.e; if (!_Json_isArray(value)) { return _Json_expecting('an ARRAY', value); } if (index >= value.length) { return _Json_expecting('a LONGER array. Need index ' + index + ' but only see ' + value.length + ' entries', value); } var result = _Json_runHelp(decoder.b, value[index]); return (elm$core$Result$isOk(result)) ? result : elm$core$Result$Err(A2(elm$json$Json$Decode$Index, index, result.a)); case 8: if (typeof value !== 'object' || value === null || _Json_isArray(value)) { return _Json_expecting('an OBJECT', value); } var keyValuePairs = _List_Nil; // TODO test perf of Object.keys and switch when support is good enough for (var key in value) { if (value.hasOwnProperty(key)) { var result = _Json_runHelp(decoder.b, value[key]); if (!elm$core$Result$isOk(result)) { return elm$core$Result$Err(A2(elm$json$Json$Decode$Field, key, result.a)); } keyValuePairs = _List_Cons(_Utils_Tuple2(key, result.a), keyValuePairs); } } return elm$core$Result$Ok(elm$core$List$reverse(keyValuePairs)); case 9: var answer = decoder.f; var decoders = decoder.g; for (var i = 0; i < decoders.length; i++) { var result = _Json_runHelp(decoders[i], value); if (!elm$core$Result$isOk(result)) { return result; } answer = answer(result.a); } return elm$core$Result$Ok(answer); case 10: var result = _Json_runHelp(decoder.b, value); return (!elm$core$Result$isOk(result)) ? result : _Json_runHelp(decoder.h(result.a), value); case 11: var errors = _List_Nil; for (var temp = decoder.g; temp.b; temp = temp.b) // WHILE_CONS { var result = _Json_runHelp(temp.a, value); if (elm$core$Result$isOk(result)) { return result; } errors = _List_Cons(result.a, errors); } return elm$core$Result$Err(elm$json$Json$Decode$OneOf(elm$core$List$reverse(errors))); case 1: return elm$core$Result$Err(A2(elm$json$Json$Decode$Failure, decoder.a, _Json_wrap(value))); case 0: return elm$core$Result$Ok(decoder.a); } } function _Json_runArrayDecoder(decoder, value, toElmValue) { var len = value.length; var array = new Array(len); for (var i = 0; i < len; i++) { var result = _Json_runHelp(decoder, value[i]); if (!elm$core$Result$isOk(result)) { return elm$core$Result$Err(A2(elm$json$Json$Decode$Index, i, result.a)); } array[i] = result.a; } return elm$core$Result$Ok(toElmValue(array)); } function _Json_isArray(value) { return Array.isArray(value) || (typeof FileList !== 'undefined' && value instanceof FileList); } function _Json_toElmArray(array) { return A2(elm$core$Array$initialize, array.length, function(i) { return array[i]; }); } function _Json_expecting(type, value) { return elm$core$Result$Err(A2(elm$json$Json$Decode$Failure, 'Expecting ' + type, _Json_wrap(value))); } // EQUALITY function _Json_equality(x, y) { if (x === y) { return true; } if (x.$ !== y.$) { return false; } switch (x.$) { case 0: case 1: return x.a === y.a; case 2: return x.b === y.b; case 5: return x.c === y.c; case 3: case 4: case 8: return _Json_equality(x.b, y.b); case 6: return x.d === y.d && _Json_equality(x.b, y.b); case 7: return x.e === y.e && _Json_equality(x.b, y.b); case 9: return x.f === y.f && _Json_listEquality(x.g, y.g); case 10: return x.h === y.h && _Json_equality(x.b, y.b); case 11: return _Json_listEquality(x.g, y.g); } } function _Json_listEquality(aDecoders, bDecoders) { var len = aDecoders.length; if (len !== bDecoders.length) { return false; } for (var i = 0; i < len; i++) { if (!_Json_equality(aDecoders[i], bDecoders[i])) { return false; } } return true; } // ENCODE var _Json_encode = F2(function(indentLevel, value) { return JSON.stringify(_Json_unwrap(value), null, indentLevel) + ''; }); function _Json_wrap(value) { return { $: 0, a: value }; } function _Json_unwrap(value) { return value.a; } function _Json_wrap_UNUSED(value) { return value; } function _Json_unwrap_UNUSED(value) { return value; } function _Json_emptyArray() { return []; } function _Json_emptyObject() { return {}; } var _Json_addField = F3(function(key, value, object) { object[key] = _Json_unwrap(value); return object; }); function _Json_addEntry(func) { return F2(function(entry, array) { array.push(_Json_unwrap(func(entry))); return array; }); } var _Json_encodeNull = _Json_wrap(null); // TASKS function _Scheduler_succeed(value) { return { $: 0, a: value }; } function _Scheduler_fail(error) { return { $: 1, a: error }; } function _Scheduler_binding(callback) { return { $: 2, b: callback, c: null }; } var _Scheduler_andThen = F2(function(callback, task) { return { $: 3, b: callback, d: task }; }); var _Scheduler_onError = F2(function(callback, task) { return { $: 4, b: callback, d: task }; }); function _Scheduler_receive(callback) { return { $: 5, b: callback }; } // PROCESSES var _Scheduler_guid = 0; function _Scheduler_rawSpawn(task) { var proc = { $: 0, e: _Scheduler_guid++, f: task, g: null, h: [] }; _Scheduler_enqueue(proc); return proc; } function _Scheduler_spawn(task) { return _Scheduler_binding(function(callback) { callback(_Scheduler_succeed(_Scheduler_rawSpawn(task))); }); } function _Scheduler_rawSend(proc, msg) { proc.h.push(msg); _Scheduler_enqueue(proc); } var _Scheduler_send = F2(function(proc, msg) { return _Scheduler_binding(function(callback) { _Scheduler_rawSend(proc, msg); callback(_Scheduler_succeed(_Utils_Tuple0)); }); }); function _Scheduler_kill(proc) { return _Scheduler_binding(function(callback) { var task = proc.f; if (task.$ === 2 && task.c) { task.c(); } proc.f = null; callback(_Scheduler_succeed(_Utils_Tuple0)); }); } /* STEP PROCESSES type alias Process = { $ : tag , id : unique_id , root : Task , stack : null | { $: SUCCEED | FAIL, a: callback, b: stack } , mailbox : [msg] } */ var _Scheduler_working = false; var _Scheduler_queue = []; function _Scheduler_enqueue(proc) { _Scheduler_queue.push(proc); if (_Scheduler_working) { return; } _Scheduler_working = true; while (proc = _Scheduler_queue.shift()) { _Scheduler_step(proc); } _Scheduler_working = false; } function _Scheduler_step(proc) { while (proc.f) { var rootTag = proc.f.$; if (rootTag === 0 || rootTag === 1) { while (proc.g && proc.g.$ !== rootTag) { proc.g = proc.g.i; } if (!proc.g) { return; } proc.f = proc.g.b(proc.f.a); proc.g = proc.g.i; } else if (rootTag === 2) { proc.f.c = proc.f.b(function(newRoot) { proc.f = newRoot; _Scheduler_enqueue(proc); }); return; } else if (rootTag === 5) { if (proc.h.length === 0) { return; } proc.f = proc.f.b(proc.h.shift()); } else // if (rootTag === 3 || rootTag === 4) { proc.g = { $: rootTag === 3 ? 0 : 1, b: proc.f.b, i: proc.g }; proc.f = proc.f.d; } } } function _Process_sleep(time) { return _Scheduler_binding(function(callback) { var id = setTimeout(function() { callback(_Scheduler_succeed(_Utils_Tuple0)); }, time); return function() { clearTimeout(id); }; }); } // PROGRAMS var _Platform_worker = F4(function(impl, flagDecoder, debugMetadata, args) { return _Platform_initialize( flagDecoder, args, impl.init, impl.update, impl.subscriptions, function() { return function() {} } ); }); // INITIALIZE A PROGRAM function _Platform_initialize(flagDecoder, args, init, update, subscriptions, stepperBuilder) { var result = A2(_Json_run, flagDecoder, _Json_wrap(args ? args['flags'] : undefined)); elm$core$Result$isOk(result) || _Debug_crash(2 /**/, _Json_errorToString(result.a) /**/); var managers = {}; result = init(result.a); var model = result.a; var stepper = stepperBuilder(sendToApp, model); var ports = _Platform_setupEffects(managers, sendToApp); function sendToApp(msg, viewMetadata) { result = A2(update, msg, model); stepper(model = result.a, viewMetadata); _Platform_dispatchEffects(managers, result.b, subscriptions(model)); } _Platform_dispatchEffects(managers, result.b, subscriptions(model)); return ports ? { ports: ports } : {}; } // TRACK PRELOADS // // This is used by code in elm/browser and elm/http // to register any HTTP requests that are triggered by init. // var _Platform_preload; function _Platform_registerPreload(url) { _Platform_preload.add(url); } // EFFECT MANAGERS var _Platform_effectManagers = {}; function _Platform_setupEffects(managers, sendToApp) { var ports; // setup all necessary effect managers for (var key in _Platform_effectManagers) { var manager = _Platform_effectManagers[key]; if (manager.a) { ports = ports || {}; ports[key] = manager.a(key, sendToApp); } managers[key] = _Platform_instantiateManager(manager, sendToApp); } return ports; } function _Platform_createManager(init, onEffects, onSelfMsg, cmdMap, subMap) { return { b: init, c: onEffects, d: onSelfMsg, e: cmdMap, f: subMap }; } function _Platform_instantiateManager(info, sendToApp) { var router = { g: sendToApp, h: undefined }; var onEffects = info.c; var onSelfMsg = info.d; var cmdMap = info.e; var subMap = info.f; function loop(state) { return A2(_Scheduler_andThen, loop, _Scheduler_receive(function(msg) { var value = msg.a; if (msg.$ === 0) { return A3(onSelfMsg, router, value, state); } return cmdMap && subMap ? A4(onEffects, router, value.i, value.j, state) : A3(onEffects, router, cmdMap ? value.i : value.j, state); })); } return router.h = _Scheduler_rawSpawn(A2(_Scheduler_andThen, loop, info.b)); } // ROUTING var _Platform_sendToApp = F2(function(router, msg) { return _Scheduler_binding(function(callback) { router.g(msg); callback(_Scheduler_succeed(_Utils_Tuple0)); }); }); var _Platform_sendToSelf = F2(function(router, msg) { return A2(_Scheduler_send, router.h, { $: 0, a: msg }); }); // BAGS function _Platform_leaf(home) { return function(value) { return { $: 1, k: home, l: value }; }; } function _Platform_batch(list) { return { $: 2, m: list }; } var _Platform_map = F2(function(tagger, bag) { return { $: 3, n: tagger, o: bag } }); // PIPE BAGS INTO EFFECT MANAGERS function _Platform_dispatchEffects(managers, cmdBag, subBag) { var effectsDict = {}; _Platform_gatherEffects(true, cmdBag, effectsDict, null); _Platform_gatherEffects(false, subBag, effectsDict, null); for (var home in managers) { _Scheduler_rawSend(managers[home], { $: 'fx', a: effectsDict[home] || { i: _List_Nil, j: _List_Nil } }); } } function _Platform_gatherEffects(isCmd, bag, effectsDict, taggers) { switch (bag.$) { case 1: var home = bag.k; var effect = _Platform_toEffect(isCmd, home, taggers, bag.l); effectsDict[home] = _Platform_insert(isCmd, effect, effectsDict[home]); return; case 2: for (var list = bag.m; list.b; list = list.b) // WHILE_CONS { _Platform_gatherEffects(isCmd, list.a, effectsDict, taggers); } return; case 3: _Platform_gatherEffects(isCmd, bag.o, effectsDict, { p: bag.n, q: taggers }); return; } } function _Platform_toEffect(isCmd, home, taggers, value) { function applyTaggers(x) { for (var temp = taggers; temp; temp = temp.q) { x = temp.p(x); } return x; } var map = isCmd ? _Platform_effectManagers[home].e : _Platform_effectManagers[home].f; return A2(map, applyTaggers, value) } function _Platform_insert(isCmd, newEffect, effects) { effects = effects || { i: _List_Nil, j: _List_Nil }; isCmd ? (effects.i = _List_Cons(newEffect, effects.i)) : (effects.j = _List_Cons(newEffect, effects.j)); return effects; } // PORTS function _Platform_checkPortName(name) { if (_Platform_effectManagers[name]) { _Debug_crash(3, name) } } // OUTGOING PORTS function _Platform_outgoingPort(name, converter) { _Platform_checkPortName(name); _Platform_effectManagers[name] = { e: _Platform_outgoingPortMap, r: converter, a: _Platform_setupOutgoingPort }; return _Platform_leaf(name); } var _Platform_outgoingPortMap = F2(function(tagger, value) { return value; }); function _Platform_setupOutgoingPort(name) { var subs = []; var converter = _Platform_effectManagers[name].r; // CREATE MANAGER var init = _Process_sleep(0); _Platform_effectManagers[name].b = init; _Platform_effectManagers[name].c = F3(function(router, cmdList, state) { for ( ; cmdList.b; cmdList = cmdList.b) // WHILE_CONS { // grab a separate reference to subs in case unsubscribe is called var currentSubs = subs; var value = _Json_unwrap(converter(cmdList.a)); for (var i = 0; i < currentSubs.length; i++) { currentSubs[i](value); } } return init; }); // PUBLIC API function subscribe(callback) { subs.push(callback); } function unsubscribe(callback) { // copy subs into a new array in case unsubscribe is called within a // subscribed callback subs = subs.slice(); var index = subs.indexOf(callback); if (index >= 0) { subs.splice(index, 1); } } return { subscribe: subscribe, unsubscribe: unsubscribe }; } // INCOMING PORTS function _Platform_incomingPort(name, converter) { _Platform_checkPortName(name); _Platform_effectManagers[name] = { f: _Platform_incomingPortMap, r: converter, a: _Platform_setupIncomingPort }; return _Platform_leaf(name); } var _Platform_incomingPortMap = F2(function(tagger, finalTagger) { return function(value) { return tagger(finalTagger(value)); }; }); function _Platform_setupIncomingPort(name, sendToApp) { var subs = _List_Nil; var converter = _Platform_effectManagers[name].r; // CREATE MANAGER var init = _Scheduler_succeed(null); _Platform_effectManagers[name].b = init; _Platform_effectManagers[name].c = F3(function(router, subList, state) { subs = subList; return init; }); // PUBLIC API function send(incomingValue) { var result = A2(_Json_run, converter, _Json_wrap(incomingValue)); elm$core$Result$isOk(result) || _Debug_crash(4, name, result.a); var value = result.a; for (var temp = subs; temp.b; temp = temp.b) // WHILE_CONS { sendToApp(temp.a(value)); } } return { send: send }; } // EXPORT ELM MODULES // // Have DEBUG and PROD versions so that we can (1) give nicer errors in // debug mode and (2) not pay for the bits needed for that in prod mode. // function _Platform_export_UNUSED(exports) { scope['Elm'] ? _Platform_mergeExportsProd(scope['Elm'], exports) : scope['Elm'] = exports; } function _Platform_mergeExportsProd(obj, exports) { for (var name in exports) { (name in obj) ? (name == 'init') ? _Debug_crash(6) : _Platform_mergeExportsProd(obj[name], exports[name]) : (obj[name] = exports[name]); } } function _Platform_export(exports) { scope['Elm'] ? _Platform_mergeExportsDebug('Elm', scope['Elm'], exports) : scope['Elm'] = exports; } function _Platform_mergeExportsDebug(moduleName, obj, exports) { for (var name in exports) { (name in obj) ? (name == 'init') ? _Debug_crash(6, moduleName) : _Platform_mergeExportsDebug(moduleName + '.' + name, obj[name], exports[name]) : (obj[name] = exports[name]); } } // SEND REQUEST var _Http_toTask = F3(function(router, toTask, request) { return _Scheduler_binding(function(callback) { function done(response) { callback(toTask(request.expect.a(response))); } var xhr = new XMLHttpRequest(); xhr.addEventListener('error', function() { done(elm$http$Http$NetworkError_); }); xhr.addEventListener('timeout', function() { done(elm$http$Http$Timeout_); }); xhr.addEventListener('load', function() { done(_Http_toResponse(request.expect.b, xhr)); }); elm$core$Maybe$isJust(request.tracker) && _Http_track(router, xhr, request.tracker.a); try { xhr.open(request.method, request.url, true); } catch (e) { return done(elm$http$Http$BadUrl_(request.url)); } _Http_configureRequest(xhr, request); request.body.a && xhr.setRequestHeader('Content-Type', request.body.a); xhr.send(request.body.b); return function() { xhr.c = true; xhr.abort(); }; }); }); // CONFIGURE function _Http_configureRequest(xhr, request) { for (var headers = request.headers; headers.b; headers = headers.b) // WHILE_CONS { xhr.setRequestHeader(headers.a.a, headers.a.b); } xhr.timeout = request.timeout.a || 0; xhr.responseType = request.expect.d; xhr.withCredentials = request.allowCookiesFromOtherDomains; } // RESPONSES function _Http_toResponse(toBody, xhr) { return A2( 200 <= xhr.status && xhr.status < 300 ? elm$http$Http$GoodStatus_ : elm$http$Http$BadStatus_, _Http_toMetadata(xhr), toBody(xhr.response) ); } // METADATA function _Http_toMetadata(xhr) { return { url: xhr.responseURL, statusCode: xhr.status, statusText: xhr.statusText, headers: _Http_parseHeaders(xhr.getAllResponseHeaders()) }; } // HEADERS function _Http_parseHeaders(rawHeaders) { if (!rawHeaders) { return elm$core$Dict$empty; } var headers = elm$core$Dict$empty; var headerPairs = rawHeaders.split('\r\n'); for (var i = headerPairs.length; i--; ) { var headerPair = headerPairs[i]; var index = headerPair.indexOf(': '); if (index > 0) { var key = headerPair.substring(0, index); var value = headerPair.substring(index + 2); headers = A3(elm$core$Dict$update, key, function(oldValue) { return elm$core$Maybe$Just(elm$core$Maybe$isJust(oldValue) ? value + ', ' + oldValue.a : value ); }, headers); } } return headers; } // EXPECT var _Http_expect = F3(function(type, toBody, toValue) { return { $: 0, d: type, b: toBody, a: toValue }; }); var _Http_mapExpect = F2(function(func, expect) { return { $: 0, d: expect.d, b: expect.b, a: function(x) { return func(expect.a(x)); } }; }); function _Http_toDataView(arrayBuffer) { return new DataView(arrayBuffer); } // BODY and PARTS var _Http_emptyBody = { $: 0 }; var _Http_pair = F2(function(a, b) { return { $: 0, a: a, b: b }; }); function _Http_toFormData(parts) { for (var formData = new FormData(); parts.b; parts = parts.b) // WHILE_CONS { var part = parts.a; formData.append(part.a, part.b); } return formData; } var _Http_bytesToBlob = F2(function(mime, bytes) { return new Blob([bytes], { type: mime }); }); // PROGRESS function _Http_track(router, xhr, tracker) { // TODO check out lengthComputable on loadstart event xhr.upload.addEventListener('progress', function(event) { if (xhr.c) { return; } _Scheduler_rawSpawn(A2(elm$core$Platform$sendToSelf, router, _Utils_Tuple2(tracker, elm$http$Http$Sending({ sent: event.loaded, size: event.total })))); }); xhr.addEventListener('progress', function(event) { if (xhr.c) { return; } _Scheduler_rawSpawn(A2(elm$core$Platform$sendToSelf, router, _Utils_Tuple2(tracker, elm$http$Http$Receiving({ received: event.loaded, size: event.lengthComputable ? elm$core$Maybe$Just(event.total) : elm$core$Maybe$Nothing })))); }); } // HELPERS var _VirtualDom_divertHrefToApp; var _VirtualDom_doc = typeof document !== 'undefined' ? document : {}; function _VirtualDom_appendChild(parent, child) { parent.appendChild(child); } var _VirtualDom_init = F4(function(virtualNode, flagDecoder, debugMetadata, args) { // NOTE: this function needs _Platform_export available to work /**_UNUSED/ var node = args['node']; //*/ /**/ var node = args && args['node'] ? args['node'] : _Debug_crash(0); //*/ node.parentNode.replaceChild( _VirtualDom_render(virtualNode, function() {}), node ); return {}; }); // TEXT function _VirtualDom_text(string) { return { $: 0, a: string }; } // NODE var _VirtualDom_nodeNS = F2(function(namespace, tag) { return F2(function(factList, kidList) { for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS { var kid = kidList.a; descendantsCount += (kid.b || 0); kids.push(kid); } descendantsCount += kids.length; return { $: 1, c: tag, d: _VirtualDom_organizeFacts(factList), e: kids, f: namespace, b: descendantsCount }; }); }); var _VirtualDom_node = _VirtualDom_nodeNS(undefined); // KEYED NODE var _VirtualDom_keyedNodeNS = F2(function(namespace, tag) { return F2(function(factList, kidList) { for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS { var kid = kidList.a; descendantsCount += (kid.b.b || 0); kids.push(kid); } descendantsCount += kids.length; return { $: 2, c: tag, d: _VirtualDom_organizeFacts(factList), e: kids, f: namespace, b: descendantsCount }; }); }); var _VirtualDom_keyedNode = _VirtualDom_keyedNodeNS(undefined); // CUSTOM function _VirtualDom_custom(factList, model, render, diff) { return { $: 3, d: _VirtualDom_organizeFacts(factList), g: model, h: render, i: diff }; } // MAP var _VirtualDom_map = F2(function(tagger, node) { return { $: 4, j: tagger, k: node, b: 1 + (node.b || 0) }; }); // LAZY function _VirtualDom_thunk(refs, thunk) { return { $: 5, l: refs, m: thunk, k: undefined }; } var _VirtualDom_lazy = F2(function(func, a) { return _VirtualDom_thunk([func, a], function() { return func(a); }); }); var _VirtualDom_lazy2 = F3(function(func, a, b) { return _VirtualDom_thunk([func, a, b], function() { return A2(func, a, b); }); }); var _VirtualDom_lazy3 = F4(function(func, a, b, c) { return _VirtualDom_thunk([func, a, b, c], function() { return A3(func, a, b, c); }); }); var _VirtualDom_lazy4 = F5(function(func, a, b, c, d) { return _VirtualDom_thunk([func, a, b, c, d], function() { return A4(func, a, b, c, d); }); }); var _VirtualDom_lazy5 = F6(function(func, a, b, c, d, e) { return _VirtualDom_thunk([func, a, b, c, d, e], function() { return A5(func, a, b, c, d, e); }); }); var _VirtualDom_lazy6 = F7(function(func, a, b, c, d, e, f) { return _VirtualDom_thunk([func, a, b, c, d, e, f], function() { return A6(func, a, b, c, d, e, f); }); }); var _VirtualDom_lazy7 = F8(function(func, a, b, c, d, e, f, g) { return _VirtualDom_thunk([func, a, b, c, d, e, f, g], function() { return A7(func, a, b, c, d, e, f, g); }); }); var _VirtualDom_lazy8 = F9(function(func, a, b, c, d, e, f, g, h) { return _VirtualDom_thunk([func, a, b, c, d, e, f, g, h], function() { return A8(func, a, b, c, d, e, f, g, h); }); }); // FACTS var _VirtualDom_on = F2(function(key, handler) { return { $: 'a0', n: key, o: handler }; }); var _VirtualDom_style = F2(function(key, value) { return { $: 'a1', n: key, o: value }; }); var _VirtualDom_property = F2(function(key, value) { return { $: 'a2', n: key, o: value }; }); var _VirtualDom_attribute = F2(function(key, value) { return { $: 'a3', n: key, o: value }; }); var _VirtualDom_attributeNS = F3(function(namespace, key, value) { return { $: 'a4', n: key, o: { f: namespace, o: value } }; }); // XSS ATTACK VECTOR CHECKS function _VirtualDom_noScript(tag) { return tag == 'script' ? 'p' : tag; } function _VirtualDom_noOnOrFormAction(key) { return /^(on|formAction$)/i.test(key) ? 'data-' + key : key; } function _VirtualDom_noInnerHtmlOrFormAction(key) { return key == 'innerHTML' || key == 'formAction' ? 'data-' + key : key; } function _VirtualDom_noJavaScriptUri_UNUSED(value) { return /^javascript:/i.test(value.replace(/\s/g,'')) ? '' : value; } function _VirtualDom_noJavaScriptUri(value) { return /^javascript:/i.test(value.replace(/\s/g,'')) ? 'javascript:alert("This is an XSS vector. Please use ports or web components instead.")' : value; } function _VirtualDom_noJavaScriptOrHtmlUri_UNUSED(value) { return /^\s*(javascript:|data:text\/html)/i.test(value) ? '' : value; } function _VirtualDom_noJavaScriptOrHtmlUri(value) { return /^\s*(javascript:|data:text\/html)/i.test(value) ? 'javascript:alert("This is an XSS vector. Please use ports or web components instead.")' : value; } // MAP FACTS var _VirtualDom_mapAttribute = F2(function(func, attr) { return (attr.$ === 'a0') ? A2(_VirtualDom_on, attr.n, _VirtualDom_mapHandler(func, attr.o)) : attr; }); function _VirtualDom_mapHandler(func, handler) { var tag = elm$virtual_dom$VirtualDom$toHandlerInt(handler); // 0 = Normal // 1 = MayStopPropagation // 2 = MayPreventDefault // 3 = Custom return { $: handler.$, a: !tag ? A2(elm$json$Json$Decode$map, func, handler.a) : A3(elm$json$Json$Decode$map2, tag < 3 ? _VirtualDom_mapEventTuple : _VirtualDom_mapEventRecord, elm$json$Json$Decode$succeed(func), handler.a ) }; } var _VirtualDom_mapEventTuple = F2(function(func, tuple) { return _Utils_Tuple2(func(tuple.a), tuple.b); }); var _VirtualDom_mapEventRecord = F2(function(func, record) { return { message: func(record.message), stopPropagation: record.stopPropagation, preventDefault: record.preventDefault } }); // ORGANIZE FACTS function _VirtualDom_organizeFacts(factList) { for (var facts = {}; factList.b; factList = factList.b) // WHILE_CONS { var entry = factList.a; var tag = entry.$; var key = entry.n; var value = entry.o; if (tag === 'a2') { (key === 'className') ? _VirtualDom_addClass(facts, key, _Json_unwrap(value)) : facts[key] = _Json_unwrap(value); continue; } var subFacts = facts[tag] || (facts[tag] = {}); (tag === 'a3' && key === 'class') ? _VirtualDom_addClass(subFacts, key, value) : subFacts[key] = value; } return facts; } function _VirtualDom_addClass(object, key, newClass) { var classes = object[key]; object[key] = classes ? classes + ' ' + newClass : newClass; } // RENDER function _VirtualDom_render(vNode, eventNode) { var tag = vNode.$; if (tag === 5) { return _VirtualDom_render(vNode.k || (vNode.k = vNode.m()), eventNode); } if (tag === 0) { return _VirtualDom_doc.createTextNode(vNode.a); } if (tag === 4) { var subNode = vNode.k; var tagger = vNode.j; while (subNode.$ === 4) { typeof tagger !== 'object' ? tagger = [tagger, subNode.j] : tagger.push(subNode.j); subNode = subNode.k; } var subEventRoot = { j: tagger, p: eventNode }; var domNode = _VirtualDom_render(subNode, subEventRoot); domNode.elm_event_node_ref = subEventRoot; return domNode; } if (tag === 3) { var domNode = vNode.h(vNode.g); _VirtualDom_applyFacts(domNode, eventNode, vNode.d); return domNode; } // at this point `tag` must be 1 or 2 var domNode = vNode.f ? _VirtualDom_doc.createElementNS(vNode.f, vNode.c) : _VirtualDom_doc.createElement(vNode.c); if (_VirtualDom_divertHrefToApp && vNode.c == 'a') { domNode.addEventListener('click', _VirtualDom_divertHrefToApp(domNode)); } _VirtualDom_applyFacts(domNode, eventNode, vNode.d); for (var kids = vNode.e, i = 0; i < kids.length; i++) { _VirtualDom_appendChild(domNode, _VirtualDom_render(tag === 1 ? kids[i] : kids[i].b, eventNode)); } return domNode; } // APPLY FACTS function _VirtualDom_applyFacts(domNode, eventNode, facts) { for (var key in facts) { var value = facts[key]; key === 'a1' ? _VirtualDom_applyStyles(domNode, value) : key === 'a0' ? _VirtualDom_applyEvents(domNode, eventNode, value) : key === 'a3' ? _VirtualDom_applyAttrs(domNode, value) : key === 'a4' ? _VirtualDom_applyAttrsNS(domNode, value) : ((key !== 'value' && key !== 'checked') || domNode[key] !== value) && (domNode[key] = value); } } // APPLY STYLES function _VirtualDom_applyStyles(domNode, styles) { var domNodeStyle = domNode.style; for (var key in styles) { domNodeStyle[key] = styles[key]; } } // APPLY ATTRS function _VirtualDom_applyAttrs(domNode, attrs) { for (var key in attrs) { var value = attrs[key]; typeof value !== 'undefined' ? domNode.setAttribute(key, value) : domNode.removeAttribute(key); } } // APPLY NAMESPACED ATTRS function _VirtualDom_applyAttrsNS(domNode, nsAttrs) { for (var key in nsAttrs) { var pair = nsAttrs[key]; var namespace = pair.f; var value = pair.o; typeof value !== 'undefined' ? domNode.setAttributeNS(namespace, key, value) : domNode.removeAttributeNS(namespace, key); } } // APPLY EVENTS function _VirtualDom_applyEvents(domNode, eventNode, events) { var allCallbacks = domNode.elmFs || (domNode.elmFs = {}); for (var key in events) { var newHandler = events[key]; var oldCallback = allCallbacks[key]; if (!newHandler) { domNode.removeEventListener(key, oldCallback); allCallbacks[key] = undefined; continue; } if (oldCallback) { var oldHandler = oldCallback.q; if (oldHandler.$ === newHandler.$) { oldCallback.q = newHandler; continue; } domNode.removeEventListener(key, oldCallback); } oldCallback = _VirtualDom_makeCallback(eventNode, newHandler); domNode.addEventListener(key, oldCallback, _VirtualDom_passiveSupported && { passive: elm$virtual_dom$VirtualDom$toHandlerInt(newHandler) < 2 } ); allCallbacks[key] = oldCallback; } } // PASSIVE EVENTS var _VirtualDom_passiveSupported; try { window.addEventListener('t', null, Object.defineProperty({}, 'passive', { get: function() { _VirtualDom_passiveSupported = true; } })); } catch(e) {} // EVENT HANDLERS function _VirtualDom_makeCallback(eventNode, initialHandler) { function callback(event) { var handler = callback.q; var result = _Json_runHelp(handler.a, event); if (!elm$core$Result$isOk(result)) { return; } var tag = elm$virtual_dom$VirtualDom$toHandlerInt(handler); // 0 = Normal // 1 = MayStopPropagation // 2 = MayPreventDefault // 3 = Custom var value = result.a; var message = !tag ? value : tag < 3 ? value.a : value.message; var stopPropagation = tag == 1 ? value.b : tag == 3 && value.stopPropagation; var currentEventNode = ( stopPropagation && event.stopPropagation(), (tag == 2 ? value.b : tag == 3 && value.preventDefault) && event.preventDefault(), eventNode ); var tagger; var i; while (tagger = currentEventNode.j) { if (typeof tagger == 'function') { message = tagger(message); } else { for (var i = tagger.length; i--; ) { message = tagger[i](message); } } currentEventNode = currentEventNode.p; } currentEventNode(message, stopPropagation); // stopPropagation implies isSync } callback.q = initialHandler; return callback; } function _VirtualDom_equalEvents(x, y) { return x.$ == y.$ && _Json_equality(x.a, y.a); } // DIFF // TODO: Should we do patches like in iOS? // // type Patch // = At Int Patch // | Batch (List Patch) // | Change ... // // How could it not be better? // function _VirtualDom_diff(x, y) { var patches = []; _VirtualDom_diffHelp(x, y, patches, 0); return patches; } function _VirtualDom_pushPatch(patches, type, index, data) { var patch = { $: type, r: index, s: data, t: undefined, u: undefined }; patches.push(patch); return patch; } function _VirtualDom_diffHelp(x, y, patches, index) { if (x === y) { return; } var xType = x.$; var yType = y.$; // Bail if you run into different types of nodes. Implies that the // structure has changed significantly and it's not worth a diff. if (xType !== yType) { if (xType === 1 && yType === 2) { y = _VirtualDom_dekey(y); yType = 1; } else { _VirtualDom_pushPatch(patches, 0, index, y); return; } } // Now we know that both nodes are the same $. switch (yType) { case 5: var xRefs = x.l; var yRefs = y.l; var i = xRefs.length; var same = i === yRefs.length; while (same && i--) { same = xRefs[i] === yRefs[i]; } if (same) { y.k = x.k; return; } y.k = y.m(); var subPatches = []; _VirtualDom_diffHelp(x.k, y.k, subPatches, 0); subPatches.length > 0 && _VirtualDom_pushPatch(patches, 1, index, subPatches); return; case 4: // gather nested taggers var xTaggers = x.j; var yTaggers = y.j; var nesting = false; var xSubNode = x.k; while (xSubNode.$ === 4) { nesting = true; typeof xTaggers !== 'object' ? xTaggers = [xTaggers, xSubNode.j] : xTaggers.push(xSubNode.j); xSubNode = xSubNode.k; } var ySubNode = y.k; while (ySubNode.$ === 4) { nesting = true; typeof yTaggers !== 'object' ? yTaggers = [yTaggers, ySubNode.j] : yTaggers.push(ySubNode.j); ySubNode = ySubNode.k; } // Just bail if different numbers of taggers. This implies the // structure of the virtual DOM has changed. if (nesting && xTaggers.length !== yTaggers.length) { _VirtualDom_pushPatch(patches, 0, index, y); return; } // check if taggers are "the same" if (nesting ? !_VirtualDom_pairwiseRefEqual(xTaggers, yTaggers) : xTaggers !== yTaggers) { _VirtualDom_pushPatch(patches, 2, index, yTaggers); } // diff everything below the taggers _VirtualDom_diffHelp(xSubNode, ySubNode, patches, index + 1); return; case 0: if (x.a !== y.a) { _VirtualDom_pushPatch(patches, 3, index, y.a); } return; case 1: _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKids); return; case 2: _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKeyedKids); return; case 3: if (x.h !== y.h) { _VirtualDom_pushPatch(patches, 0, index, y); return; } var factsDiff = _VirtualDom_diffFacts(x.d, y.d); factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff); var patch = y.i(x.g, y.g); patch && _VirtualDom_pushPatch(patches, 5, index, patch); return; } } // assumes the incoming arrays are the same length function _VirtualDom_pairwiseRefEqual(as, bs) { for (var i = 0; i < as.length; i++) { if (as[i] !== bs[i]) { return false; } } return true; } function _VirtualDom_diffNodes(x, y, patches, index, diffKids) { // Bail if obvious indicators have changed. Implies more serious // structural changes such that it's not worth it to diff. if (x.c !== y.c || x.f !== y.f) { _VirtualDom_pushPatch(patches, 0, index, y); return; } var factsDiff = _VirtualDom_diffFacts(x.d, y.d); factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff); diffKids(x, y, patches, index); } // DIFF FACTS // TODO Instead of creating a new diff object, it's possible to just test if // there *is* a diff. During the actual patch, do the diff again and make the // modifications directly. This way, there's no new allocations. Worth it? function _VirtualDom_diffFacts(x, y, category) { var diff; // look for changes and removals for (var xKey in x) { if (xKey === 'a1' || xKey === 'a0' || xKey === 'a3' || xKey === 'a4') { var subDiff = _VirtualDom_diffFacts(x[xKey], y[xKey] || {}, xKey); if (subDiff) { diff = diff || {}; diff[xKey] = subDiff; } continue; } // remove if not in the new facts if (!(xKey in y)) { diff = diff || {}; diff[xKey] = !category ? (typeof x[xKey] === 'string' ? '' : null) : (category === 'a1') ? '' : (category === 'a0' || category === 'a3') ? undefined : { f: x[xKey].f, o: undefined }; continue; } var xValue = x[xKey]; var yValue = y[xKey]; // reference equal, so don't worry about it if (xValue === yValue && xKey !== 'value' && xKey !== 'checked' || category === 'a0' && _VirtualDom_equalEvents(xValue, yValue)) { continue; } diff = diff || {}; diff[xKey] = yValue; } // add new stuff for (var yKey in y) { if (!(yKey in x)) { diff = diff || {}; diff[yKey] = y[yKey]; } } return diff; } // DIFF KIDS function _VirtualDom_diffKids(xParent, yParent, patches, index) { var xKids = xParent.e; var yKids = yParent.e; var xLen = xKids.length; var yLen = yKids.length; // FIGURE OUT IF THERE ARE INSERTS OR REMOVALS if (xLen > yLen) { _VirtualDom_pushPatch(patches, 6, index, { v: yLen, i: xLen - yLen }); } else if (xLen < yLen) { _VirtualDom_pushPatch(patches, 7, index, { v: xLen, e: yKids }); } // PAIRWISE DIFF EVERYTHING ELSE for (var minLen = xLen < yLen ? xLen : yLen, i = 0; i < minLen; i++) { var xKid = xKids[i]; _VirtualDom_diffHelp(xKid, yKids[i], patches, ++index); index += xKid.b || 0; } } // KEYED DIFF function _VirtualDom_diffKeyedKids(xParent, yParent, patches, rootIndex) { var localPatches = []; var changes = {}; // Dict String Entry var inserts = []; // Array { index : Int, entry : Entry } // type Entry = { tag : String, vnode : VNode, index : Int, data : _ } var xKids = xParent.e; var yKids = yParent.e; var xLen = xKids.length; var yLen = yKids.length; var xIndex = 0; var yIndex = 0; var index = rootIndex; while (xIndex < xLen && yIndex < yLen) { var x = xKids[xIndex]; var y = yKids[yIndex]; var xKey = x.a; var yKey = y.a; var xNode = x.b; var yNode = y.b; var newMatch = undefined; var oldMatch = undefined; // check if keys match if (xKey === yKey) { index++; _VirtualDom_diffHelp(xNode, yNode, localPatches, index); index += xNode.b || 0; xIndex++; yIndex++; continue; } // look ahead 1 to detect insertions and removals. var xNext = xKids[xIndex + 1]; var yNext = yKids[yIndex + 1]; if (xNext) { var xNextKey = xNext.a; var xNextNode = xNext.b; oldMatch = yKey === xNextKey; } if (yNext) { var yNextKey = yNext.a; var yNextNode = yNext.b; newMatch = xKey === yNextKey; } // swap x and y if (newMatch && oldMatch) { index++; _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index); _VirtualDom_insertNode(changes, localPatches, xKey, yNode, yIndex, inserts); index += xNode.b || 0; index++; _VirtualDom_removeNode(changes, localPatches, xKey, xNextNode, index); index += xNextNode.b || 0; xIndex += 2; yIndex += 2; continue; } // insert y if (newMatch) { index++; _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts); _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index); index += xNode.b || 0; xIndex += 1; yIndex += 2; continue; } // remove x if (oldMatch) { index++; _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index); index += xNode.b || 0; index++; _VirtualDom_diffHelp(xNextNode, yNode, localPatches, index); index += xNextNode.b || 0; xIndex += 2; yIndex += 1; continue; } // remove x, insert y if (xNext && xNextKey === yNextKey) { index++; _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index); _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts); index += xNode.b || 0; index++; _VirtualDom_diffHelp(xNextNode, yNextNode, localPatches, index); index += xNextNode.b || 0; xIndex += 2; yIndex += 2; continue; } break; } // eat up any remaining nodes with removeNode and insertNode while (xIndex < xLen) { index++; var x = xKids[xIndex]; var xNode = x.b; _VirtualDom_removeNode(changes, localPatches, x.a, xNode, index); index += xNode.b || 0; xIndex++; } while (yIndex < yLen) { var endInserts = endInserts || []; var y = yKids[yIndex]; _VirtualDom_insertNode(changes, localPatches, y.a, y.b, undefined, endInserts); yIndex++; } if (localPatches.length > 0 || inserts.length > 0 || endInserts) { _VirtualDom_pushPatch(patches, 8, rootIndex, { w: localPatches, x: inserts, y: endInserts }); } } // CHANGES FROM KEYED DIFF var _VirtualDom_POSTFIX = '_elmW6BL'; function _VirtualDom_insertNode(changes, localPatches, key, vnode, yIndex, inserts) { var entry = changes[key]; // never seen this key before if (!entry) { entry = { c: 0, z: vnode, r: yIndex, s: undefined }; inserts.push({ r: yIndex, A: entry }); changes[key] = entry; return; } // this key was removed earlier, a match! if (entry.c === 1) { inserts.push({ r: yIndex, A: entry }); entry.c = 2; var subPatches = []; _VirtualDom_diffHelp(entry.z, vnode, subPatches, entry.r); entry.r = yIndex; entry.s.s = { w: subPatches, A: entry }; return; } // this key has already been inserted or moved, a duplicate! _VirtualDom_insertNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, yIndex, inserts); } function _VirtualDom_removeNode(changes, localPatches, key, vnode, index) { var entry = changes[key]; // never seen this key before if (!entry) { var patch = _VirtualDom_pushPatch(localPatches, 9, index, undefined); changes[key] = { c: 1, z: vnode, r: index, s: patch }; return; } // this key was inserted earlier, a match! if (entry.c === 0) { entry.c = 2; var subPatches = []; _VirtualDom_diffHelp(vnode, entry.z, subPatches, index); _VirtualDom_pushPatch(localPatches, 9, index, { w: subPatches, A: entry }); return; } // this key has already been removed or moved, a duplicate! _VirtualDom_removeNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, index); } // ADD DOM NODES // // Each DOM node has an "index" assigned in order of traversal. It is important // to minimize our crawl over the actual DOM, so these indexes (along with the // descendantsCount of virtual nodes) let us skip touching entire subtrees of // the DOM if we know there are no patches there. function _VirtualDom_addDomNodes(domNode, vNode, patches, eventNode) { _VirtualDom_addDomNodesHelp(domNode, vNode, patches, 0, 0, vNode.b, eventNode); } // assumes `patches` is non-empty and indexes increase monotonically. function _VirtualDom_addDomNodesHelp(domNode, vNode, patches, i, low, high, eventNode) { var patch = patches[i]; var index = patch.r; while (index === low) { var patchType = patch.$; if (patchType === 1) { _VirtualDom_addDomNodes(domNode, vNode.k, patch.s, eventNode); } else if (patchType === 8) { patch.t = domNode; patch.u = eventNode; var subPatches = patch.s.w; if (subPatches.length > 0) { _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode); } } else if (patchType === 9) { patch.t = domNode; patch.u = eventNode; var data = patch.s; if (data) { data.A.s = domNode; var subPatches = data.w; if (subPatches.length > 0) { _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode); } } } else { patch.t = domNode; patch.u = eventNode; } i++; if (!(patch = patches[i]) || (index = patch.r) > high) { return i; } } var tag = vNode.$; if (tag === 4) { var subNode = vNode.k; while (subNode.$ === 4) { subNode = subNode.k; } return _VirtualDom_addDomNodesHelp(domNode, subNode, patches, i, low + 1, high, domNode.elm_event_node_ref); } // tag must be 1 or 2 at this point var vKids = vNode.e; var childNodes = domNode.childNodes; for (var j = 0; j < vKids.length; j++) { low++; var vKid = tag === 1 ? vKids[j] : vKids[j].b; var nextLow = low + (vKid.b || 0); if (low <= index && index <= nextLow) { i = _VirtualDom_addDomNodesHelp(childNodes[j], vKid, patches, i, low, nextLow, eventNode); if (!(patch = patches[i]) || (index = patch.r) > high) { return i; } } low = nextLow; } return i; } // APPLY PATCHES function _VirtualDom_applyPatches(rootDomNode, oldVirtualNode, patches, eventNode) { if (patches.length === 0) { return rootDomNode; } _VirtualDom_addDomNodes(rootDomNode, oldVirtualNode, patches, eventNode); return _VirtualDom_applyPatchesHelp(rootDomNode, patches); } function _VirtualDom_applyPatchesHelp(rootDomNode, patches) { for (var i = 0; i < patches.length; i++) { var patch = patches[i]; var localDomNode = patch.t var newNode = _VirtualDom_applyPatch(localDomNode, patch); if (localDomNode === rootDomNode) { rootDomNode = newNode; } } return rootDomNode; } function _VirtualDom_applyPatch(domNode, patch) { switch (patch.$) { case 0: return _VirtualDom_applyPatchRedraw(domNode, patch.s, patch.u); case 4: _VirtualDom_applyFacts(domNode, patch.u, patch.s); return domNode; case 3: domNode.replaceData(0, domNode.length, patch.s); return domNode; case 1: return _VirtualDom_applyPatchesHelp(domNode, patch.s); case 2: if (domNode.elm_event_node_ref) { domNode.elm_event_node_ref.j = patch.s; } else { domNode.elm_event_node_ref = { j: patch.s, p: patch.u }; } return domNode; case 6: var data = patch.s; for (var i = 0; i < data.i; i++) { domNode.removeChild(domNode.childNodes[data.v]); } return domNode; case 7: var data = patch.s; var kids = data.e; var i = data.v; var theEnd = domNode.childNodes[i]; for (; i < kids.length; i++) { domNode.insertBefore(_VirtualDom_render(kids[i], patch.u), theEnd); } return domNode; case 9: var data = patch.s; if (!data) { domNode.parentNode.removeChild(domNode); return domNode; } var entry = data.A; if (typeof entry.r !== 'undefined') { domNode.parentNode.removeChild(domNode); } entry.s = _VirtualDom_applyPatchesHelp(domNode, data.w); return domNode; case 8: return _VirtualDom_applyPatchReorder(domNode, patch); case 5: return patch.s(domNode); default: _Debug_crash(10); // 'Ran into an unknown patch!' } } function _VirtualDom_applyPatchRedraw(domNode, vNode, eventNode) { var parentNode = domNode.parentNode; var newNode = _VirtualDom_render(vNode, eventNode); if (!newNode.elm_event_node_ref) { newNode.elm_event_node_ref = domNode.elm_event_node_ref; } if (parentNode && newNode !== domNode) { parentNode.replaceChild(newNode, domNode); } return newNode; } function _VirtualDom_applyPatchReorder(domNode, patch) { var data = patch.s; // remove end inserts var frag = _VirtualDom_applyPatchReorderEndInsertsHelp(data.y, patch); // removals domNode = _VirtualDom_applyPatchesHelp(domNode, data.w); // inserts var inserts = data.x; for (var i = 0; i < inserts.length; i++) { var insert = inserts[i]; var entry = insert.A; var node = entry.c === 2 ? entry.s : _VirtualDom_render(entry.z, patch.u); domNode.insertBefore(node, domNode.childNodes[insert.r]); } // add end inserts if (frag) { _VirtualDom_appendChild(domNode, frag); } return domNode; } function _VirtualDom_applyPatchReorderEndInsertsHelp(endInserts, patch) { if (!endInserts) { return; } var frag = _VirtualDom_doc.createDocumentFragment(); for (var i = 0; i < endInserts.length; i++) { var insert = endInserts[i]; var entry = insert.A; _VirtualDom_appendChild(frag, entry.c === 2 ? entry.s : _VirtualDom_render(entry.z, patch.u) ); } return frag; } function _VirtualDom_virtualize(node) { // TEXT NODES if (node.nodeType === 3) { return _VirtualDom_text(node.textContent); } // WEIRD NODES if (node.nodeType !== 1) { return _VirtualDom_text(''); } // ELEMENT NODES var attrList = _List_Nil; var attrs = node.attributes; for (var i = attrs.length; i--; ) { var attr = attrs[i]; var name = attr.name; var value = attr.value; attrList = _List_Cons( A2(_VirtualDom_attribute, name, value), attrList ); } var tag = node.tagName.toLowerCase(); var kidList = _List_Nil; var kids = node.childNodes; for (var i = kids.length; i--; ) { kidList = _List_Cons(_VirtualDom_virtualize(kids[i]), kidList); } return A3(_VirtualDom_node, tag, attrList, kidList); } function _VirtualDom_dekey(keyedNode) { var keyedKids = keyedNode.e; var len = keyedKids.length; var kids = new Array(len); for (var i = 0; i < len; i++) { kids[i] = keyedKids[i].b; } return { $: 1, c: keyedNode.c, d: keyedNode.d, e: kids, f: keyedNode.f, b: keyedNode.b }; } // ELEMENT var _Debugger_element; var _Browser_element = _Debugger_element || F4(function(impl, flagDecoder, debugMetadata, args) { return _Platform_initialize( flagDecoder, args, impl.init, impl.update, impl.subscriptions, function(sendToApp, initialModel) { var view = impl.view; /**_UNUSED/ var domNode = args['node']; //*/ /**/ var domNode = args && args['node'] ? args['node'] : _Debug_crash(0); //*/ var currNode = _VirtualDom_virtualize(domNode); return _Browser_makeAnimator(initialModel, function(model) { var nextNode = view(model); var patches = _VirtualDom_diff(currNode, nextNode); domNode = _VirtualDom_applyPatches(domNode, currNode, patches, sendToApp); currNode = nextNode; }); } ); }); // DOCUMENT var _Debugger_document; var _Browser_document = _Debugger_document || F4(function(impl, flagDecoder, debugMetadata, args) { return _Platform_initialize( flagDecoder, args, impl.init, impl.update, impl.subscriptions, function(sendToApp, initialModel) { var divertHrefToApp = impl.setup && impl.setup(sendToApp) var view = impl.view; var title = _VirtualDom_doc.title; var bodyNode = _VirtualDom_doc.body; var currNode = _VirtualDom_virtualize(bodyNode); return _Browser_makeAnimator(initialModel, function(model) { _VirtualDom_divertHrefToApp = divertHrefToApp; var doc = view(model); var nextNode = _VirtualDom_node('body')(_List_Nil)(doc.body); var patches = _VirtualDom_diff(currNode, nextNode); bodyNode = _VirtualDom_applyPatches(bodyNode, currNode, patches, sendToApp); currNode = nextNode; _VirtualDom_divertHrefToApp = 0; (title !== doc.title) && (_VirtualDom_doc.title = title = doc.title); }); } ); }); // ANIMATION var _Browser_cancelAnimationFrame = typeof cancelAnimationFrame !== 'undefined' ? cancelAnimationFrame : function(id) { clearTimeout(id); }; var _Browser_requestAnimationFrame = typeof requestAnimationFrame !== 'undefined' ? requestAnimationFrame : function(callback) { return setTimeout(callback, 1000 / 60); }; function _Browser_makeAnimator(model, draw) { draw(model); var state = 0; function updateIfNeeded() { state = state === 1 ? 0 : ( _Browser_requestAnimationFrame(updateIfNeeded), draw(model), 1 ); } return function(nextModel, isSync) { model = nextModel; isSync ? ( draw(model), state === 2 && (state = 1) ) : ( state === 0 && _Browser_requestAnimationFrame(updateIfNeeded), state = 2 ); }; } // APPLICATION function _Browser_application(impl) { var onUrlChange = impl.onUrlChange; var onUrlRequest = impl.onUrlRequest; var key = function() { key.a(onUrlChange(_Browser_getUrl())); }; return _Browser_document({ setup: function(sendToApp) { key.a = sendToApp; _Browser_window.addEventListener('popstate', key); _Browser_window.navigator.userAgent.indexOf('Trident') < 0 || _Browser_window.addEventListener('hashchange', key); return F2(function(domNode, event) { if (!event.ctrlKey && !event.metaKey && !event.shiftKey && event.button < 1 && !domNode.target && !domNode.hasAttribute('download')) { event.preventDefault(); var href = domNode.href; var curr = _Browser_getUrl(); var next = elm$url$Url$fromString(href).a; sendToApp(onUrlRequest( (next && curr.protocol === next.protocol && curr.host === next.host && curr.port_.a === next.port_.a ) ? elm$browser$Browser$Internal(next) : elm$browser$Browser$External(href) )); } }); }, init: function(flags) { return A3(impl.init, flags, _Browser_getUrl(), key); }, view: impl.view, update: impl.update, subscriptions: impl.subscriptions }); } function _Browser_getUrl() { return elm$url$Url$fromString(_VirtualDom_doc.location.href).a || _Debug_crash(1); } var _Browser_go = F2(function(key, n) { return A2(elm$core$Task$perform, elm$core$Basics$never, _Scheduler_binding(function() { n && history.go(n); key(); })); }); var _Browser_pushUrl = F2(function(key, url) { return A2(elm$core$Task$perform, elm$core$Basics$never, _Scheduler_binding(function() { history.pushState({}, '', url); key(); })); }); var _Browser_replaceUrl = F2(function(key, url) { return A2(elm$core$Task$perform, elm$core$Basics$never, _Scheduler_binding(function() { history.replaceState({}, '', url); key(); })); }); // GLOBAL EVENTS var _Browser_fakeNode = { addEventListener: function() {}, removeEventListener: function() {} }; var _Browser_doc = typeof document !== 'undefined' ? document : _Browser_fakeNode; var _Browser_window = typeof window !== 'undefined' ? window : _Browser_fakeNode; var _Browser_on = F3(function(node, eventName, sendToSelf) { return _Scheduler_spawn(_Scheduler_binding(function(callback) { function handler(event) { _Scheduler_rawSpawn(sendToSelf(event)); } node.addEventListener(eventName, handler, _VirtualDom_passiveSupported && { passive: true }); return function() { node.removeEventListener(eventName, handler); }; })); }); var _Browser_decodeEvent = F2(function(decoder, event) { var result = _Json_runHelp(decoder, event); return elm$core$Result$isOk(result) ? elm$core$Maybe$Just(result.a) : elm$core$Maybe$Nothing; }); // PAGE VISIBILITY function _Browser_visibilityInfo() { return (typeof _VirtualDom_doc.hidden !== 'undefined') ? { hidden: 'hidden', change: 'visibilitychange' } : (typeof _VirtualDom_doc.mozHidden !== 'undefined') ? { hidden: 'mozHidden', change: 'mozvisibilitychange' } : (typeof _VirtualDom_doc.msHidden !== 'undefined') ? { hidden: 'msHidden', change: 'msvisibilitychange' } : (typeof _VirtualDom_doc.webkitHidden !== 'undefined') ? { hidden: 'webkitHidden', change: 'webkitvisibilitychange' } : { hidden: 'hidden', change: 'visibilitychange' }; } // ANIMATION FRAMES function _Browser_rAF() { return _Scheduler_binding(function(callback) { var id = _Browser_requestAnimationFrame(function() { callback(_Scheduler_succeed(Date.now())); }); return function() { _Browser_cancelAnimationFrame(id); }; }); } function _Browser_now() { return _Scheduler_binding(function(callback) { callback(_Scheduler_succeed(Date.now())); }); } // DOM STUFF function _Browser_withNode(id, doStuff) { return _Scheduler_binding(function(callback) { _Browser_requestAnimationFrame(function() { var node = document.getElementById(id); callback(node ? _Scheduler_succeed(doStuff(node)) : _Scheduler_fail(elm$browser$Browser$Dom$NotFound(id)) ); }); }); } function _Browser_withWindow(doStuff) { return _Scheduler_binding(function(callback) { _Browser_requestAnimationFrame(function() { callback(_Scheduler_succeed(doStuff())); }); }); } // FOCUS and BLUR var _Browser_call = F2(function(functionName, id) { return _Browser_withNode(id, function(node) { node[functionName](); return _Utils_Tuple0; }); }); // WINDOW VIEWPORT function _Browser_getViewport() { return { scene: _Browser_getScene(), viewport: { x: _Browser_window.pageXOffset, y: _Browser_window.pageYOffset, width: _Browser_doc.documentElement.clientWidth, height: _Browser_doc.documentElement.clientHeight } }; } function _Browser_getScene() { var body = _Browser_doc.body; var elem = _Browser_doc.documentElement; return { width: Math.max(body.scrollWidth, body.offsetWidth, elem.scrollWidth, elem.offsetWidth, elem.clientWidth), height: Math.max(body.scrollHeight, body.offsetHeight, elem.scrollHeight, elem.offsetHeight, elem.clientHeight) }; } var _Browser_setViewport = F2(function(x, y) { return _Browser_withWindow(function() { _Browser_window.scroll(x, y); return _Utils_Tuple0; }); }); // ELEMENT VIEWPORT function _Browser_getViewportOf(id) { return _Browser_withNode(id, function(node) { return { scene: { width: node.scrollWidth, height: node.scrollHeight }, viewport: { x: node.scrollLeft, y: node.scrollTop, width: node.clientWidth, height: node.clientHeight } }; }); } var _Browser_setViewportOf = F3(function(id, x, y) { return _Browser_withNode(id, function(node) { node.scrollLeft = x; node.scrollTop = y; return _Utils_Tuple0; }); }); // ELEMENT function _Browser_getElement(id) { return _Browser_withNode(id, function(node) { var rect = node.getBoundingClientRect(); var x = _Browser_window.pageXOffset; var y = _Browser_window.pageYOffset; return { scene: _Browser_getScene(), viewport: { x: x, y: y, width: _Browser_doc.documentElement.clientWidth, height: _Browser_doc.documentElement.clientHeight }, element: { x: x + rect.left, y: y + rect.top, width: rect.width, height: rect.height } }; }); } // LOAD and RELOAD function _Browser_reload(skipCache) { return A2(elm$core$Task$perform, elm$core$Basics$never, _Scheduler_binding(function(callback) { _VirtualDom_doc.location.reload(skipCache); })); } function _Browser_load(url) { return A2(elm$core$Task$perform, elm$core$Basics$never, _Scheduler_binding(function(callback) { try { _Browser_window.location = url; } catch(err) { // Only Firefox can throw a NS_ERROR_MALFORMED_URI exception here. // Other browsers reload the page, so let's be consistent about that. _VirtualDom_doc.location.reload(false); } })); } var author$project$Main$Comment = F3( function (author, content, saved) { return {author: author, content: content, saved: saved}; }); var author$project$Main$Model = F3( function (comments, form, loaded) { return {comments: comments, form: form, loaded: loaded}; }); var elm$core$Basics$False = {$: 'False'}; var elm$core$Basics$EQ = {$: 'EQ'}; var elm$core$Basics$LT = {$: 'LT'}; var elm$core$Elm$JsArray$foldr = _JsArray_foldr; var elm$core$Array$foldr = F3( function (func, baseCase, _n0) { var tree = _n0.c; var tail = _n0.d; var helper = F2( function (node, acc) { if (node.$ === 'SubTree') { var subTree = node.a; return A3(elm$core$Elm$JsArray$foldr, helper, acc, subTree); } else { var values = node.a; return A3(elm$core$Elm$JsArray$foldr, func, acc, values); } }); return A3( elm$core$Elm$JsArray$foldr, helper, A3(elm$core$Elm$JsArray$foldr, func, baseCase, tail), tree); }); var elm$core$List$cons = _List_cons; var elm$core$Array$toList = function (array) { return A3(elm$core$Array$foldr, elm$core$List$cons, _List_Nil, array); }; var elm$core$Basics$GT = {$: 'GT'}; var elm$core$Dict$foldr = F3( function (func, acc, t) { foldr: while (true) { if (t.$ === 'RBEmpty_elm_builtin') { return acc; } else { var key = t.b; var value = t.c; var left = t.d; var right = t.e; var $temp$func = func, $temp$acc = A3( func, key, value, A3(elm$core$Dict$foldr, func, acc, right)), $temp$t = left; func = $temp$func; acc = $temp$acc; t = $temp$t; continue foldr; } } }); var elm$core$Dict$toList = function (dict) { return A3( elm$core$Dict$foldr, F3( function (key, value, list) { return A2( elm$core$List$cons, _Utils_Tuple2(key, value), list); }), _List_Nil, dict); }; var elm$core$Dict$keys = function (dict) { return A3( elm$core$Dict$foldr, F3( function (key, value, keyList) { return A2(elm$core$List$cons, key, keyList); }), _List_Nil, dict); }; var elm$core$Set$toList = function (_n0) { var dict = _n0.a; return elm$core$Dict$keys(dict); }; var author$project$Main$initialModel = A3( author$project$Main$Model, _List_Nil, A3(author$project$Main$Comment, '', '', false), false); var author$project$Main$ApiCall = function (a) { return {$: 'ApiCall', a: a}; }; var elm$core$Basics$apR = F2( function (x, f) { return f(x); }); var elm$core$Array$branchFactor = 32; var elm$core$Array$Array_elm_builtin = F4( function (a, b, c, d) { return {$: 'Array_elm_builtin', a: a, b: b, c: c, d: d}; }); var elm$core$Basics$ceiling = _Basics_ceiling; var elm$core$Basics$fdiv = _Basics_fdiv; var elm$core$Basics$logBase = F2( function (base, number) { return _Basics_log(number) / _Basics_log(base); }); var elm$core$Basics$toFloat = _Basics_toFloat; var elm$core$Array$shiftStep = elm$core$Basics$ceiling( A2(elm$core$Basics$logBase, 2, elm$core$Array$branchFactor)); var elm$core$Elm$JsArray$empty = _JsArray_empty; var elm$core$Array$empty = A4(elm$core$Array$Array_elm_builtin, 0, elm$core$Array$shiftStep, elm$core$Elm$JsArray$empty, elm$core$Elm$JsArray$empty); var elm$core$Array$Leaf = function (a) { return {$: 'Leaf', a: a}; }; var elm$core$Array$SubTree = function (a) { return {$: 'SubTree', a: a}; }; var elm$core$Elm$JsArray$initializeFromList = _JsArray_initializeFromList; var elm$core$List$foldl = F3( function (func, acc, list) { foldl: while (true) { if (!list.b) { return acc; } else { var x = list.a; var xs = list.b; var $temp$func = func, $temp$acc = A2(func, x, acc), $temp$list = xs; func = $temp$func; acc = $temp$acc; list = $temp$list; continue foldl; } } }); var elm$core$List$reverse = function (list) { return A3(elm$core$List$foldl, elm$core$List$cons, _List_Nil, list); }; var elm$core$Array$compressNodes = F2( function (nodes, acc) { compressNodes: while (true) { var _n0 = A2(elm$core$Elm$JsArray$initializeFromList, elm$core$Array$branchFactor, nodes); var node = _n0.a; var remainingNodes = _n0.b; var newAcc = A2( elm$core$List$cons, elm$core$Array$SubTree(node), acc); if (!remainingNodes.b) { return elm$core$List$reverse(newAcc); } else { var $temp$nodes = remainingNodes, $temp$acc = newAcc; nodes = $temp$nodes; acc = $temp$acc; continue compressNodes; } } }); var elm$core$Basics$eq = _Utils_equal; var elm$core$Tuple$first = function (_n0) { var x = _n0.a; return x; }; var elm$core$Array$treeFromBuilder = F2( function (nodeList, nodeListSize) { treeFromBuilder: while (true) { var newNodeSize = elm$core$Basics$ceiling(nodeListSize / elm$core$Array$branchFactor); if (newNodeSize === 1) { return A2(elm$core$Elm$JsArray$initializeFromList, elm$core$Array$branchFactor, nodeList).a; } else { var $temp$nodeList = A2(elm$core$Array$compressNodes, nodeList, _List_Nil), $temp$nodeListSize = newNodeSize; nodeList = $temp$nodeList; nodeListSize = $temp$nodeListSize; continue treeFromBuilder; } } }); var elm$core$Basics$add = _Basics_add; var elm$core$Basics$apL = F2( function (f, x) { return f(x); }); var elm$core$Basics$floor = _Basics_floor; var elm$core$Basics$gt = _Utils_gt; var elm$core$Basics$max = F2( function (x, y) { return (_Utils_cmp(x, y) > 0) ? x : y; }); var elm$core$Basics$mul = _Basics_mul; var elm$core$Basics$sub = _Basics_sub; var elm$core$Elm$JsArray$length = _JsArray_length; var elm$core$Array$builderToArray = F2( function (reverseNodeList, builder) { if (!builder.nodeListSize) { return A4( elm$core$Array$Array_elm_builtin, elm$core$Elm$JsArray$length(builder.tail), elm$core$Array$shiftStep, elm$core$Elm$JsArray$empty, builder.tail); } else { var treeLen = builder.nodeListSize * elm$core$Array$branchFactor; var depth = elm$core$Basics$floor( A2(elm$core$Basics$logBase, elm$core$Array$branchFactor, treeLen - 1)); var correctNodeList = reverseNodeList ? elm$core$List$reverse(builder.nodeList) : builder.nodeList; var tree = A2(elm$core$Array$treeFromBuilder, correctNodeList, builder.nodeListSize); return A4( elm$core$Array$Array_elm_builtin, elm$core$Elm$JsArray$length(builder.tail) + treeLen, A2(elm$core$Basics$max, 5, depth * elm$core$Array$shiftStep), tree, builder.tail); } }); var elm$core$Basics$idiv = _Basics_idiv; var elm$core$Basics$lt = _Utils_lt; var elm$core$Elm$JsArray$initialize = _JsArray_initialize; var elm$core$Array$initializeHelp = F5( function (fn, fromIndex, len, nodeList, tail) { initializeHelp: while (true) { if (fromIndex < 0) { return A2( elm$core$Array$builderToArray, false, {nodeList: nodeList, nodeListSize: (len / elm$core$Array$branchFactor) | 0, tail: tail}); } else { var leaf = elm$core$Array$Leaf( A3(elm$core$Elm$JsArray$initialize, elm$core$Array$branchFactor, fromIndex, fn)); var $temp$fn = fn, $temp$fromIndex = fromIndex - elm$core$Array$branchFactor, $temp$len = len, $temp$nodeList = A2(elm$core$List$cons, leaf, nodeList), $temp$tail = tail; fn = $temp$fn; fromIndex = $temp$fromIndex; len = $temp$len; nodeList = $temp$nodeList; tail = $temp$tail; continue initializeHelp; } } }); var elm$core$Basics$le = _Utils_le; var elm$core$Basics$remainderBy = _Basics_remainderBy; var elm$core$Array$initialize = F2( function (len, fn) { if (len <= 0) { return elm$core$Array$empty; } else { var tailLen = len % elm$core$Array$branchFactor; var tail = A3(elm$core$Elm$JsArray$initialize, tailLen, len - tailLen, fn); var initialFromIndex = (len - tailLen) - elm$core$Array$branchFactor; return A5(elm$core$Array$initializeHelp, fn, initialFromIndex, len, _List_Nil, tail); } }); var elm$core$Maybe$Just = function (a) { return {$: 'Just', a: a}; }; var elm$core$Maybe$Nothing = {$: 'Nothing'}; var elm$core$Result$Err = function (a) { return {$: 'Err', a: a}; }; var elm$core$Result$Ok = function (a) { return {$: 'Ok', a: a}; }; var elm$core$Basics$True = {$: 'True'}; var elm$core$Result$isOk = function (result) { if (result.$ === 'Ok') { return true; } else { return false; } }; var elm$json$Json$Decode$Failure = F2( function (a, b) { return {$: 'Failure', a: a, b: b}; }); var elm$json$Json$Decode$Field = F2( function (a, b) { return {$: 'Field', a: a, b: b}; }); var elm$json$Json$Decode$Index = F2( function (a, b) { return {$: 'Index', a: a, b: b}; }); var elm$json$Json$Decode$OneOf = function (a) { return {$: 'OneOf', a: a}; }; var elm$core$Basics$and = _Basics_and; var elm$core$Basics$append = _Utils_append; var elm$core$Basics$or = _Basics_or; var elm$core$Char$toCode = _Char_toCode; var elm$core$Char$isLower = function (_char) { var code = elm$core$Char$toCode(_char); return (97 <= code) && (code <= 122); }; var elm$core$Char$isUpper = function (_char) { var code = elm$core$Char$toCode(_char); return (code <= 90) && (65 <= code); }; var elm$core$Char$isAlpha = function (_char) { return elm$core$Char$isLower(_char) || elm$core$Char$isUpper(_char); }; var elm$core$Char$isDigit = function (_char) { var code = elm$core$Char$toCode(_char); return (code <= 57) && (48 <= code); }; var elm$core$Char$isAlphaNum = function (_char) { return elm$core$Char$isLower(_char) || (elm$core$Char$isUpper(_char) || elm$core$Char$isDigit(_char)); }; var elm$core$List$length = function (xs) { return A3( elm$core$List$foldl, F2( function (_n0, i) { return i + 1; }), 0, xs); }; var elm$core$List$map2 = _List_map2; var elm$core$List$rangeHelp = F3( function (lo, hi, list) { rangeHelp: while (true) { if (_Utils_cmp(lo, hi) < 1) { var $temp$lo = lo, $temp$hi = hi - 1, $temp$list = A2(elm$core$List$cons, hi, list); lo = $temp$lo; hi = $temp$hi; list = $temp$list; continue rangeHelp; } else { return list; } } }); var elm$core$List$range = F2( function (lo, hi) { return A3(elm$core$List$rangeHelp, lo, hi, _List_Nil); }); var elm$core$List$indexedMap = F2( function (f, xs) { return A3( elm$core$List$map2, f, A2( elm$core$List$range, 0, elm$core$List$length(xs) - 1), xs); }); var elm$core$String$all = _String_all; var elm$core$String$fromInt = _String_fromNumber; var elm$core$String$join = F2( function (sep, chunks) { return A2( _String_join, sep, _List_toArray(chunks)); }); var elm$core$String$uncons = _String_uncons; var elm$core$String$split = F2( function (sep, string) { return _List_fromArray( A2(_String_split, sep, string)); }); var elm$json$Json$Decode$indent = function (str) { return A2( elm$core$String$join, '\n ', A2(elm$core$String$split, '\n', str)); }; var elm$json$Json$Encode$encode = _Json_encode; var elm$json$Json$Decode$errorOneOf = F2( function (i, error) { return '\n\n(' + (elm$core$String$fromInt(i + 1) + (') ' + elm$json$Json$Decode$indent( elm$json$Json$Decode$errorToString(error)))); }); var elm$json$Json$Decode$errorToString = function (error) { return A2(elm$json$Json$Decode$errorToStringHelp, error, _List_Nil); }; var elm$json$Json$Decode$errorToStringHelp = F2( function (error, context) { errorToStringHelp: while (true) { switch (error.$) { case 'Field': var f = error.a; var err = error.b; var isSimple = function () { var _n1 = elm$core$String$uncons(f); if (_n1.$ === 'Nothing') { return false; } else { var _n2 = _n1.a; var _char = _n2.a; var rest = _n2.b; return elm$core$Char$isAlpha(_char) && A2(elm$core$String$all, elm$core$Char$isAlphaNum, rest); } }(); var fieldName = isSimple ? ('.' + f) : ('[\'' + (f + '\']')); var $temp$error = err, $temp$context = A2(elm$core$List$cons, fieldName, context); error = $temp$error; context = $temp$context; continue errorToStringHelp; case 'Index': var i = error.a; var err = error.b; var indexName = '[' + (elm$core$String$fromInt(i) + ']'); var $temp$error = err, $temp$context = A2(elm$core$List$cons, indexName, context); error = $temp$error; context = $temp$context; continue errorToStringHelp; case 'OneOf': var errors = error.a; if (!errors.b) { return 'Ran into a Json.Decode.oneOf with no possibilities' + function () { if (!context.b) { return '!'; } else { return ' at json' + A2( elm$core$String$join, '', elm$core$List$reverse(context)); } }(); } else { if (!errors.b.b) { var err = errors.a; var $temp$error = err, $temp$context = context; error = $temp$error; context = $temp$context; continue errorToStringHelp; } else { var starter = function () { if (!context.b) { return 'Json.Decode.oneOf'; } else { return 'The Json.Decode.oneOf at json' + A2( elm$core$String$join, '', elm$core$List$reverse(context)); } }(); var introduction = starter + (' failed in the following ' + (elm$core$String$fromInt( elm$core$List$length(errors)) + ' ways:')); return A2( elm$core$String$join, '\n\n', A2( elm$core$List$cons, introduction, A2(elm$core$List$indexedMap, elm$json$Json$Decode$errorOneOf, errors))); } } default: var msg = error.a; var json = error.b; var introduction = function () { if (!context.b) { return 'Problem with the given value:\n\n'; } else { return 'Problem with the value at json' + (A2( elm$core$String$join, '', elm$core$List$reverse(context)) + ':\n\n '); } }(); return introduction + (elm$json$Json$Decode$indent( A2(elm$json$Json$Encode$encode, 4, json)) + ('\n\n' + msg)); } } }); var elm$json$Json$Decode$map2 = _Json_map2; var NoRedInk$elm_json_decode_pipeline$Json$Decode$Pipeline$custom = elm$json$Json$Decode$map2(elm$core$Basics$apR); var elm$core$Basics$composeR = F3( function (f, g, x) { return g( f(x)); }); var elm$json$Json$Decode$succeed = _Json_succeed; var NoRedInk$elm_json_decode_pipeline$Json$Decode$Pipeline$hardcoded = A2(elm$core$Basics$composeR, elm$json$Json$Decode$succeed, NoRedInk$elm_json_decode_pipeline$Json$Decode$Pipeline$custom); var elm$json$Json$Decode$field = _Json_decodeField; var NoRedInk$elm_json_decode_pipeline$Json$Decode$Pipeline$required = F3( function (key, valDecoder, decoder) { return A2( NoRedInk$elm_json_decode_pipeline$Json$Decode$Pipeline$custom, A2(elm$json$Json$Decode$field, key, valDecoder), decoder); }); var elm$json$Json$Decode$string = _Json_decodeString; var author$project$Main$decodeComment = A2( NoRedInk$elm_json_decode_pipeline$Json$Decode$Pipeline$hardcoded, true, A3( NoRedInk$elm_json_decode_pipeline$Json$Decode$Pipeline$required, 'content', elm$json$Json$Decode$string, A3( NoRedInk$elm_json_decode_pipeline$Json$Decode$Pipeline$required, 'author', elm$json$Json$Decode$string, elm$json$Json$Decode$succeed(author$project$Main$Comment)))); var elm$json$Json$Decode$list = _Json_decodeList; var author$project$Main$decode = A2( elm$json$Json$Decode$field, 'comments', elm$json$Json$Decode$list(author$project$Main$decodeComment)); var elm$core$Result$mapError = F2( function (f, result) { if (result.$ === 'Ok') { var v = result.a; return elm$core$Result$Ok(v); } else { var e = result.a; return elm$core$Result$Err( f(e)); } }); var elm$core$Basics$identity = function (x) { return x; }; var elm$core$Dict$RBEmpty_elm_builtin = {$: 'RBEmpty_elm_builtin'}; var elm$core$Dict$empty = elm$core$Dict$RBEmpty_elm_builtin; var elm$core$Basics$compare = _Utils_compare; var elm$core$Dict$get = F2( function (targetKey, dict) { get: while (true) { if (dict.$ === 'RBEmpty_elm_builtin') { return elm$core$Maybe$Nothing; } else { var key = dict.b; var value = dict.c; var left = dict.d; var right = dict.e; var _n1 = A2(elm$core$Basics$compare, targetKey, key); switch (_n1.$) { case 'LT': var $temp$targetKey = targetKey, $temp$dict = left; targetKey = $temp$targetKey; dict = $temp$dict; continue get; case 'EQ': return elm$core$Maybe$Just(value); default: var $temp$targetKey = targetKey, $temp$dict = right; targetKey = $temp$targetKey; dict = $temp$dict; continue get; } } } }); var elm$core$Dict$Black = {$: 'Black'}; var elm$core$Dict$RBNode_elm_builtin = F5( function (a, b, c, d, e) { return {$: 'RBNode_elm_builtin', a: a, b: b, c: c, d: d, e: e}; }); var elm$core$Dict$Red = {$: 'Red'}; var elm$core$Dict$balance = F5( function (color, key, value, left, right) { if ((right.$ === 'RBNode_elm_builtin') && (right.a.$ === 'Red')) { var _n1 = right.a; var rK = right.b; var rV = right.c; var rLeft = right.d; var rRight = right.e; if ((left.$ === 'RBNode_elm_builtin') && (left.a.$ === 'Red')) { var _n3 = left.a; var lK = left.b; var lV = left.c; var lLeft = left.d; var lRight = left.e; return A5( elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, key, value, A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, lK, lV, lLeft, lRight), A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, rK, rV, rLeft, rRight)); } else { return A5( elm$core$Dict$RBNode_elm_builtin, color, rK, rV, A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, key, value, left, rLeft), rRight); } } else { if ((((left.$ === 'RBNode_elm_builtin') && (left.a.$ === 'Red')) && (left.d.$ === 'RBNode_elm_builtin')) && (left.d.a.$ === 'Red')) { var _n5 = left.a; var lK = left.b; var lV = left.c; var _n6 = left.d; var _n7 = _n6.a; var llK = _n6.b; var llV = _n6.c; var llLeft = _n6.d; var llRight = _n6.e; var lRight = left.e; return A5( elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, lK, lV, A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, llK, llV, llLeft, llRight), A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, key, value, lRight, right)); } else { return A5(elm$core$Dict$RBNode_elm_builtin, color, key, value, left, right); } } }); var elm$core$Dict$insertHelp = F3( function (key, value, dict) { if (dict.$ === 'RBEmpty_elm_builtin') { return A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, key, value, elm$core$Dict$RBEmpty_elm_builtin, elm$core$Dict$RBEmpty_elm_builtin); } else { var nColor = dict.a; var nKey = dict.b; var nValue = dict.c; var nLeft = dict.d; var nRight = dict.e; var _n1 = A2(elm$core$Basics$compare, key, nKey); switch (_n1.$) { case 'LT': return A5( elm$core$Dict$balance, nColor, nKey, nValue, A3(elm$core$Dict$insertHelp, key, value, nLeft), nRight); case 'EQ': return A5(elm$core$Dict$RBNode_elm_builtin, nColor, nKey, value, nLeft, nRight); default: return A5( elm$core$Dict$balance, nColor, nKey, nValue, nLeft, A3(elm$core$Dict$insertHelp, key, value, nRight)); } } }); var elm$core$Dict$insert = F3( function (key, value, dict) { var _n0 = A3(elm$core$Dict$insertHelp, key, value, dict); if ((_n0.$ === 'RBNode_elm_builtin') && (_n0.a.$ === 'Red')) { var _n1 = _n0.a; var k = _n0.b; var v = _n0.c; var l = _n0.d; var r = _n0.e; return A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, k, v, l, r); } else { var x = _n0; return x; } }); var elm$core$Dict$getMin = function (dict) { getMin: while (true) { if ((dict.$ === 'RBNode_elm_builtin') && (dict.d.$ === 'RBNode_elm_builtin')) { var left = dict.d; var $temp$dict = left; dict = $temp$dict; continue getMin; } else { return dict; } } }; var elm$core$Dict$moveRedLeft = function (dict) { if (((dict.$ === 'RBNode_elm_builtin') && (dict.d.$ === 'RBNode_elm_builtin')) && (dict.e.$ === 'RBNode_elm_builtin')) { if ((dict.e.d.$ === 'RBNode_elm_builtin') && (dict.e.d.a.$ === 'Red')) { var clr = dict.a; var k = dict.b; var v = dict.c; var _n1 = dict.d; var lClr = _n1.a; var lK = _n1.b; var lV = _n1.c; var lLeft = _n1.d; var lRight = _n1.e; var _n2 = dict.e; var rClr = _n2.a; var rK = _n2.b; var rV = _n2.c; var rLeft = _n2.d; var _n3 = rLeft.a; var rlK = rLeft.b; var rlV = rLeft.c; var rlL = rLeft.d; var rlR = rLeft.e; var rRight = _n2.e; return A5( elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, rlK, rlV, A5( elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, k, v, A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, lK, lV, lLeft, lRight), rlL), A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, rK, rV, rlR, rRight)); } else { var clr = dict.a; var k = dict.b; var v = dict.c; var _n4 = dict.d; var lClr = _n4.a; var lK = _n4.b; var lV = _n4.c; var lLeft = _n4.d; var lRight = _n4.e; var _n5 = dict.e; var rClr = _n5.a; var rK = _n5.b; var rV = _n5.c; var rLeft = _n5.d; var rRight = _n5.e; if (clr.$ === 'Black') { return A5( elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, k, v, A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, lK, lV, lLeft, lRight), A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, rK, rV, rLeft, rRight)); } else { return A5( elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, k, v, A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, lK, lV, lLeft, lRight), A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, rK, rV, rLeft, rRight)); } } } else { return dict; } }; var elm$core$Dict$moveRedRight = function (dict) { if (((dict.$ === 'RBNode_elm_builtin') && (dict.d.$ === 'RBNode_elm_builtin')) && (dict.e.$ === 'RBNode_elm_builtin')) { if ((dict.d.d.$ === 'RBNode_elm_builtin') && (dict.d.d.a.$ === 'Red')) { var clr = dict.a; var k = dict.b; var v = dict.c; var _n1 = dict.d; var lClr = _n1.a; var lK = _n1.b; var lV = _n1.c; var _n2 = _n1.d; var _n3 = _n2.a; var llK = _n2.b; var llV = _n2.c; var llLeft = _n2.d; var llRight = _n2.e; var lRight = _n1.e; var _n4 = dict.e; var rClr = _n4.a; var rK = _n4.b; var rV = _n4.c; var rLeft = _n4.d; var rRight = _n4.e; return A5( elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, lK, lV, A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, llK, llV, llLeft, llRight), A5( elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, k, v, lRight, A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, rK, rV, rLeft, rRight))); } else { var clr = dict.a; var k = dict.b; var v = dict.c; var _n5 = dict.d; var lClr = _n5.a; var lK = _n5.b; var lV = _n5.c; var lLeft = _n5.d; var lRight = _n5.e; var _n6 = dict.e; var rClr = _n6.a; var rK = _n6.b; var rV = _n6.c; var rLeft = _n6.d; var rRight = _n6.e; if (clr.$ === 'Black') { return A5( elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, k, v, A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, lK, lV, lLeft, lRight), A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, rK, rV, rLeft, rRight)); } else { return A5( elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, k, v, A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, lK, lV, lLeft, lRight), A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, rK, rV, rLeft, rRight)); } } } else { return dict; } }; var elm$core$Dict$removeHelpPrepEQGT = F7( function (targetKey, dict, color, key, value, left, right) { if ((left.$ === 'RBNode_elm_builtin') && (left.a.$ === 'Red')) { var _n1 = left.a; var lK = left.b; var lV = left.c; var lLeft = left.d; var lRight = left.e; return A5( elm$core$Dict$RBNode_elm_builtin, color, lK, lV, lLeft, A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Red, key, value, lRight, right)); } else { _n2$2: while (true) { if ((right.$ === 'RBNode_elm_builtin') && (right.a.$ === 'Black')) { if (right.d.$ === 'RBNode_elm_builtin') { if (right.d.a.$ === 'Black') { var _n3 = right.a; var _n4 = right.d; var _n5 = _n4.a; return elm$core$Dict$moveRedRight(dict); } else { break _n2$2; } } else { var _n6 = right.a; var _n7 = right.d; return elm$core$Dict$moveRedRight(dict); } } else { break _n2$2; } } return dict; } }); var elm$core$Dict$removeMin = function (dict) { if ((dict.$ === 'RBNode_elm_builtin') && (dict.d.$ === 'RBNode_elm_builtin')) { var color = dict.a; var key = dict.b; var value = dict.c; var left = dict.d; var lColor = left.a; var lLeft = left.d; var right = dict.e; if (lColor.$ === 'Black') { if ((lLeft.$ === 'RBNode_elm_builtin') && (lLeft.a.$ === 'Red')) { var _n3 = lLeft.a; return A5( elm$core$Dict$RBNode_elm_builtin, color, key, value, elm$core$Dict$removeMin(left), right); } else { var _n4 = elm$core$Dict$moveRedLeft(dict); if (_n4.$ === 'RBNode_elm_builtin') { var nColor = _n4.a; var nKey = _n4.b; var nValue = _n4.c; var nLeft = _n4.d; var nRight = _n4.e; return A5( elm$core$Dict$balance, nColor, nKey, nValue, elm$core$Dict$removeMin(nLeft), nRight); } else { return elm$core$Dict$RBEmpty_elm_builtin; } } } else { return A5( elm$core$Dict$RBNode_elm_builtin, color, key, value, elm$core$Dict$removeMin(left), right); } } else { return elm$core$Dict$RBEmpty_elm_builtin; } }; var elm$core$Dict$removeHelp = F2( function (targetKey, dict) { if (dict.$ === 'RBEmpty_elm_builtin') { return elm$core$Dict$RBEmpty_elm_builtin; } else { var color = dict.a; var key = dict.b; var value = dict.c; var left = dict.d; var right = dict.e; if (_Utils_cmp(targetKey, key) < 0) { if ((left.$ === 'RBNode_elm_builtin') && (left.a.$ === 'Black')) { var _n4 = left.a; var lLeft = left.d; if ((lLeft.$ === 'RBNode_elm_builtin') && (lLeft.a.$ === 'Red')) { var _n6 = lLeft.a; return A5( elm$core$Dict$RBNode_elm_builtin, color, key, value, A2(elm$core$Dict$removeHelp, targetKey, left), right); } else { var _n7 = elm$core$Dict$moveRedLeft(dict); if (_n7.$ === 'RBNode_elm_builtin') { var nColor = _n7.a; var nKey = _n7.b; var nValue = _n7.c; var nLeft = _n7.d; var nRight = _n7.e; return A5( elm$core$Dict$balance, nColor, nKey, nValue, A2(elm$core$Dict$removeHelp, targetKey, nLeft), nRight); } else { return elm$core$Dict$RBEmpty_elm_builtin; } } } else { return A5( elm$core$Dict$RBNode_elm_builtin, color, key, value, A2(elm$core$Dict$removeHelp, targetKey, left), right); } } else { return A2( elm$core$Dict$removeHelpEQGT, targetKey, A7(elm$core$Dict$removeHelpPrepEQGT, targetKey, dict, color, key, value, left, right)); } } }); var elm$core$Dict$removeHelpEQGT = F2( function (targetKey, dict) { if (dict.$ === 'RBNode_elm_builtin') { var color = dict.a; var key = dict.b; var value = dict.c; var left = dict.d; var right = dict.e; if (_Utils_eq(targetKey, key)) { var _n1 = elm$core$Dict$getMin(right); if (_n1.$ === 'RBNode_elm_builtin') { var minKey = _n1.b; var minValue = _n1.c; return A5( elm$core$Dict$balance, color, minKey, minValue, left, elm$core$Dict$removeMin(right)); } else { return elm$core$Dict$RBEmpty_elm_builtin; } } else { return A5( elm$core$Dict$balance, color, key, value, left, A2(elm$core$Dict$removeHelp, targetKey, right)); } } else { return elm$core$Dict$RBEmpty_elm_builtin; } }); var elm$core$Dict$remove = F2( function (key, dict) { var _n0 = A2(elm$core$Dict$removeHelp, key, dict); if ((_n0.$ === 'RBNode_elm_builtin') && (_n0.a.$ === 'Red')) { var _n1 = _n0.a; var k = _n0.b; var v = _n0.c; var l = _n0.d; var r = _n0.e; return A5(elm$core$Dict$RBNode_elm_builtin, elm$core$Dict$Black, k, v, l, r); } else { var x = _n0; return x; } }); var elm$core$Dict$update = F3( function (targetKey, alter, dictionary) { var _n0 = alter( A2(elm$core$Dict$get, targetKey, dictionary)); if (_n0.$ === 'Just') { var value = _n0.a; return A3(elm$core$Dict$insert, targetKey, value, dictionary); } else { return A2(elm$core$Dict$remove, targetKey, dictionary); } }); var elm$core$Maybe$isJust = function (maybe) { if (maybe.$ === 'Just') { return true; } else { return false; } }; var elm$core$Platform$sendToApp = _Platform_sendToApp; var elm$core$Platform$sendToSelf = _Platform_sendToSelf; var elm$core$Result$map = F2( function (func, ra) { if (ra.$ === 'Ok') { var a = ra.a; return elm$core$Result$Ok( func(a)); } else { var e = ra.a; return elm$core$Result$Err(e); } }); var elm$http$Http$BadStatus_ = F2( function (a, b) { return {$: 'BadStatus_', a: a, b: b}; }); var elm$http$Http$BadUrl_ = function (a) { return {$: 'BadUrl_', a: a}; }; var elm$http$Http$GoodStatus_ = F2( function (a, b) { return {$: 'GoodStatus_', a: a, b: b}; }); var elm$http$Http$NetworkError_ = {$: 'NetworkError_'}; var elm$http$Http$Receiving = function (a) { return {$: 'Receiving', a: a}; }; var elm$http$Http$Sending = function (a) { return {$: 'Sending', a: a}; }; var elm$http$Http$Timeout_ = {$: 'Timeout_'}; var elm$http$Http$expectStringResponse = F2( function (toMsg, toResult) { return A3( _Http_expect, '', elm$core$Basics$identity, A2(elm$core$Basics$composeR, toResult, toMsg)); }); var elm$http$Http$BadBody = function (a) { return {$: 'BadBody', a: a}; }; var elm$http$Http$BadStatus = function (a) { return {$: 'BadStatus', a: a}; }; var elm$http$Http$BadUrl = function (a) { return {$: 'BadUrl', a: a}; }; var elm$http$Http$NetworkError = {$: 'NetworkError'}; var elm$http$Http$Timeout = {$: 'Timeout'}; var elm$http$Http$resolve = F2( function (toResult, response) { switch (response.$) { case 'BadUrl_': var url = response.a; return elm$core$Result$Err( elm$http$Http$BadUrl(url)); case 'Timeout_': return elm$core$Result$Err(elm$http$Http$Timeout); case 'NetworkError_': return elm$core$Result$Err(elm$http$Http$NetworkError); case 'BadStatus_': var metadata = response.a; return elm$core$Result$Err( elm$http$Http$BadStatus(metadata.statusCode)); default: var body = response.b; return A2( elm$core$Result$mapError, elm$http$Http$BadBody, toResult(body)); } }); var elm$json$Json$Decode$decodeString = _Json_runOnString; var elm$http$Http$expectJson = F2( function (toMsg, decoder) { return A2( elm$http$Http$expectStringResponse, toMsg, elm$http$Http$resolve( function (string) { return A2( elm$core$Result$mapError, elm$json$Json$Decode$errorToString, A2(elm$json$Json$Decode$decodeString, decoder, string)); })); }); var elm$http$Http$emptyBody = _Http_emptyBody; var elm$http$Http$Request = function (a) { return {$: 'Request', a: a}; }; var elm$core$Task$succeed = _Scheduler_succeed; var elm$http$Http$State = F2( function (reqs, subs) { return {reqs: reqs, subs: subs}; }); var elm$http$Http$init = elm$core$Task$succeed( A2(elm$http$Http$State, elm$core$Dict$empty, _List_Nil)); var elm$core$Task$andThen = _Scheduler_andThen; var elm$core$Process$kill = _Scheduler_kill; var elm$core$Process$spawn = _Scheduler_spawn; var elm$http$Http$updateReqs = F3( function (router, cmds, reqs) { updateReqs: while (true) { if (!cmds.b) { return elm$core$Task$succeed(reqs); } else { var cmd = cmds.a; var otherCmds = cmds.b; if (cmd.$ === 'Cancel') { var tracker = cmd.a; var _n2 = A2(elm$core$Dict$get, tracker, reqs); if (_n2.$ === 'Nothing') { var $temp$router = router, $temp$cmds = otherCmds, $temp$reqs = reqs; router = $temp$router; cmds = $temp$cmds; reqs = $temp$reqs; continue updateReqs; } else { var pid = _n2.a; return A2( elm$core$Task$andThen, function (_n3) { return A3( elm$http$Http$updateReqs, router, otherCmds, A2(elm$core$Dict$remove, tracker, reqs)); }, elm$core$Process$kill(pid)); } } else { var req = cmd.a; return A2( elm$core$Task$andThen, function (pid) { var _n4 = req.tracker; if (_n4.$ === 'Nothing') { return A3(elm$http$Http$updateReqs, router, otherCmds, reqs); } else { var tracker = _n4.a; return A3( elm$http$Http$updateReqs, router, otherCmds, A3(elm$core$Dict$insert, tracker, pid, reqs)); } }, elm$core$Process$spawn( A3( _Http_toTask, router, elm$core$Platform$sendToApp(router), req))); } } } }); var elm$http$Http$onEffects = F4( function (router, cmds, subs, state) { return A2( elm$core$Task$andThen, function (reqs) { return elm$core$Task$succeed( A2(elm$http$Http$State, reqs, subs)); }, A3(elm$http$Http$updateReqs, router, cmds, state.reqs)); }); var elm$core$List$foldrHelper = F4( function (fn, acc, ctr, ls) { if (!ls.b) { return acc; } else { var a = ls.a; var r1 = ls.b; if (!r1.b) { return A2(fn, a, acc); } else { var b = r1.a; var r2 = r1.b; if (!r2.b) { return A2( fn, a, A2(fn, b, acc)); } else { var c = r2.a; var r3 = r2.b; if (!r3.b) { return A2( fn, a, A2( fn, b, A2(fn, c, acc))); } else { var d = r3.a; var r4 = r3.b; var res = (ctr > 500) ? A3( elm$core$List$foldl, fn, acc, elm$core$List$reverse(r4)) : A4(elm$core$List$foldrHelper, fn, acc, ctr + 1, r4); return A2( fn, a, A2( fn, b, A2( fn, c, A2(fn, d, res)))); } } } } }); var elm$core$List$foldr = F3( function (fn, acc, ls) { return A4(elm$core$List$foldrHelper, fn, acc, 0, ls); }); var elm$core$List$maybeCons = F3( function (f, mx, xs) { var _n0 = f(mx); if (_n0.$ === 'Just') { var x = _n0.a; return A2(elm$core$List$cons, x, xs); } else { return xs; } }); var elm$core$List$filterMap = F2( function (f, xs) { return A3( elm$core$List$foldr, elm$core$List$maybeCons(f), _List_Nil, xs); }); var elm$core$Task$map2 = F3( function (func, taskA, taskB) { return A2( elm$core$Task$andThen, function (a) { return A2( elm$core$Task$andThen, function (b) { return elm$core$Task$succeed( A2(func, a, b)); }, taskB); }, taskA); }); var elm$core$Task$sequence = function (tasks) { return A3( elm$core$List$foldr, elm$core$Task$map2(elm$core$List$cons), elm$core$Task$succeed(_List_Nil), tasks); }; var elm$http$Http$maybeSend = F4( function (router, desiredTracker, progress, _n0) { var actualTracker = _n0.a; var toMsg = _n0.b; return _Utils_eq(desiredTracker, actualTracker) ? elm$core$Maybe$Just( A2( elm$core$Platform$sendToApp, router, toMsg(progress))) : elm$core$Maybe$Nothing; }); var elm$http$Http$onSelfMsg = F3( function (router, _n0, state) { var tracker = _n0.a; var progress = _n0.b; return A2( elm$core$Task$andThen, function (_n1) { return elm$core$Task$succeed(state); }, elm$core$Task$sequence( A2( elm$core$List$filterMap, A3(elm$http$Http$maybeSend, router, tracker, progress), state.subs))); }); var elm$http$Http$Cancel = function (a) { return {$: 'Cancel', a: a}; }; var elm$http$Http$cmdMap = F2( function (func, cmd) { if (cmd.$ === 'Cancel') { var tracker = cmd.a; return elm$http$Http$Cancel(tracker); } else { var r = cmd.a; return elm$http$Http$Request( { allowCookiesFromOtherDomains: r.allowCookiesFromOtherDomains, body: r.body, expect: A2(_Http_mapExpect, func, r.expect), headers: r.headers, method: r.method, timeout: r.timeout, tracker: r.tracker, url: r.url }); } }); var elm$http$Http$MySub = F2( function (a, b) { return {$: 'MySub', a: a, b: b}; }); var elm$http$Http$subMap = F2( function (func, _n0) { var tracker = _n0.a; var toMsg = _n0.b; return A2( elm$http$Http$MySub, tracker, A2(elm$core$Basics$composeR, toMsg, func)); }); _Platform_effectManagers['Http'] = _Platform_createManager(elm$http$Http$init, elm$http$Http$onEffects, elm$http$Http$onSelfMsg, elm$http$Http$cmdMap, elm$http$Http$subMap); var elm$http$Http$command = _Platform_leaf('Http'); var elm$http$Http$subscription = _Platform_leaf('Http'); var elm$http$Http$request = function (r) { return elm$http$Http$command( elm$http$Http$Request( {allowCookiesFromOtherDomains: false, body: r.body, expect: r.expect, headers: r.headers, method: r.method, timeout: r.timeout, tracker: r.tracker, url: r.url})); }; var elm$http$Http$get = function (r) { return elm$http$Http$request( {body: elm$http$Http$emptyBody, expect: r.expect, headers: _List_Nil, method: 'GET', timeout: elm$core$Maybe$Nothing, tracker: elm$core$Maybe$Nothing, url: r.url}); }; var author$project$Main$loadComments = elm$http$Http$get( { expect: A2(elm$http$Http$expectJson, author$project$Main$ApiCall, author$project$Main$decode), url: 'http://vamosaprenderelm.herokuapp.com/api/comments' }); var author$project$Main$init = function (flags) { return _Utils_Tuple2(author$project$Main$initialModel, author$project$Main$loadComments); }; var author$project$Main$resetForm = function (model) { return _Utils_update( model, { form: A3(author$project$Main$Comment, '', '', false) }); }; var author$project$Main$ApiPost = function (a) { return {$: 'ApiPost', a: a}; }; var elm$http$Http$jsonBody = function (value) { return A2( _Http_pair, 'application/json', A2(elm$json$Json$Encode$encode, 0, value)); }; var elm$http$Http$post = function (r) { return elm$http$Http$request( {body: r.body, expect: r.expect, headers: _List_Nil, method: 'POST', timeout: elm$core$Maybe$Nothing, tracker: elm$core$Maybe$Nothing, url: r.url}); }; var elm$json$Json$Encode$object = function (pairs) { return _Json_wrap( A3( elm$core$List$foldl, F2( function (_n0, obj) { var k = _n0.a; var v = _n0.b; return A3(_Json_addField, k, v, obj); }), _Json_emptyObject(_Utils_Tuple0), pairs)); }; var elm$json$Json$Encode$string = _Json_wrap; var author$project$Main$saveComment = function (comment) { var data = elm$json$Json$Encode$object( _List_fromArray( [ _Utils_Tuple2( 'author', elm$json$Json$Encode$string(comment.author)), _Utils_Tuple2( 'content', elm$json$Json$Encode$string(comment.content)) ])); return elm$http$Http$post( { body: elm$http$Http$jsonBody(data), expect: A2(elm$http$Http$expectJson, author$project$Main$ApiPost, author$project$Main$decodeComment), url: 'http://vamosaprenderelm.herokuapp.com/api/comments/' }); }; var author$project$Main$updateCommentStatus = F2( function (_new, current) { return (_Utils_eq(current.author, _new.author) && _Utils_eq(current.content, _new.content)) ? _Utils_update( current, {saved: true}) : current; }); var elm$core$List$map = F2( function (f, xs) { return A3( elm$core$List$foldr, F2( function (x, acc) { return A2( elm$core$List$cons, f(x), acc); }), _List_Nil, xs); }); var author$project$Main$updateCommentsStatus = F2( function (newComment, comments) { return A2( elm$core$List$map, author$project$Main$updateCommentStatus(newComment), comments); }); var elm$core$List$append = F2( function (xs, ys) { if (!ys.b) { return xs; } else { return A3(elm$core$List$foldr, elm$core$List$cons, ys, xs); } }); var elm$core$Platform$Cmd$batch = _Platform_batch; var elm$core$Platform$Cmd$none = elm$core$Platform$Cmd$batch(_List_Nil); var elm$core$String$isEmpty = function (string) { return string === ''; }; var elm$core$String$trim = _String_trim; var author$project$Main$update = F2( function (msg, model) { switch (msg.$) { case 'LoadComments': return _Utils_Tuple2(model, author$project$Main$loadComments); case 'ApiSuccess': var comments = msg.a; return _Utils_Tuple2( author$project$Main$resetForm(model), elm$core$Platform$Cmd$none); case 'ApiCall': var result = msg.a; if (result.$ === 'Ok') { var comments = result.a; var modell = _Utils_update( model, {comments: comments, loaded: true}); return _Utils_Tuple2(modell, elm$core$Platform$Cmd$none); } else { return _Utils_Tuple2(model, elm$core$Platform$Cmd$none); } case 'ApiPost': var result = msg.a; if (result.$ === 'Ok') { var comment = result.a; var newComments = A2(author$project$Main$updateCommentsStatus, comment, model.comments); var modell = _Utils_update( model, {comments: newComments, loaded: true}); return _Utils_Tuple2(modell, elm$core$Platform$Cmd$none); } else { return _Utils_Tuple2(model, elm$core$Platform$Cmd$none); } case 'RessetForm': return _Utils_Tuple2( author$project$Main$resetForm(model), elm$core$Platform$Cmd$none); case 'PostComment': var content = elm$core$String$trim(model.form.content); var author = elm$core$String$trim(model.form.author); var modell = (elm$core$String$isEmpty(author) && elm$core$String$isEmpty(content)) ? model : _Utils_update( model, { comments: A2( elm$core$List$append, model.comments, _List_fromArray( [model.form])) }); return _Utils_Tuple2( author$project$Main$resetForm(modell), author$project$Main$saveComment(model.form)); case 'UpdateAuthor': var value = msg.a; return _Utils_Tuple2( _Utils_update( model, { form: A3(author$project$Main$Comment, value, model.form.content, false) }), elm$core$Platform$Cmd$none); default: var value = msg.a; return _Utils_Tuple2( _Utils_update( model, { form: A3(author$project$Main$Comment, model.form.author, value, false) }), elm$core$Platform$Cmd$none); } }); var author$project$Main$PostComment = {$: 'PostComment'}; var author$project$Main$UpdateAuthor = function (a) { return {$: 'UpdateAuthor', a: a}; }; var author$project$Main$UpdateContent = function (a) { return {$: 'UpdateContent', a: a}; }; var author$project$Main$pluralize = F2( function (name, count) { return (count === 1) ? name : (name + 's'); }); var elm$json$Json$Decode$map = _Json_map1; var elm$virtual_dom$VirtualDom$toHandlerInt = function (handler) { switch (handler.$) { case 'Normal': return 0; case 'MayStopPropagation': return 1; case 'MayPreventDefault': return 2; default: return 3; } }; var elm$html$Html$br = _VirtualDom_node('br'); var elm$html$Html$li = _VirtualDom_node('li'); var elm$html$Html$strong = _VirtualDom_node('strong'); var elm$virtual_dom$VirtualDom$text = _VirtualDom_text; var elm$html$Html$text = elm$virtual_dom$VirtualDom$text; var elm$html$Html$Attributes$stringProperty = F2( function (key, string) { return A2( _VirtualDom_property, key, elm$json$Json$Encode$string(string)); }); var elm$html$Html$Attributes$class = elm$html$Html$Attributes$stringProperty('className'); var author$project$Main$viewComment = function (comment) { var commentClass = comment.saved ? '' : 'saving'; return A2( elm$html$Html$li, _List_fromArray( [ elm$html$Html$Attributes$class(commentClass) ]), _List_fromArray( [ A2( elm$html$Html$strong, _List_Nil, _List_fromArray( [ elm$html$Html$text(comment.author) ])), A2(elm$html$Html$br, _List_Nil, _List_Nil), elm$html$Html$text(comment.content) ])); }; var elm$html$Html$button = _VirtualDom_node('button'); var elm$html$Html$div = _VirtualDom_node('div'); var elm$html$Html$form = _VirtualDom_node('form'); var elm$html$Html$h1 = _VirtualDom_node('h1'); var elm$html$Html$h3 = _VirtualDom_node('h3'); var elm$html$Html$input = _VirtualDom_node('input'); var elm$html$Html$label = _VirtualDom_node('label'); var elm$html$Html$textarea = _VirtualDom_node('textarea'); var elm$html$Html$ul = _VirtualDom_node('ul'); var elm$html$Html$Attributes$value = elm$html$Html$Attributes$stringProperty('value'); var elm$html$Html$Events$alwaysStop = function (x) { return _Utils_Tuple2(x, true); }; var elm$virtual_dom$VirtualDom$MayStopPropagation = function (a) { return {$: 'MayStopPropagation', a: a}; }; var elm$virtual_dom$VirtualDom$on = _VirtualDom_on; var elm$html$Html$Events$stopPropagationOn = F2( function (event, decoder) { return A2( elm$virtual_dom$VirtualDom$on, event, elm$virtual_dom$VirtualDom$MayStopPropagation(decoder)); }); var elm$json$Json$Decode$at = F2( function (fields, decoder) { return A3(elm$core$List$foldr, elm$json$Json$Decode$field, decoder, fields); }); var elm$html$Html$Events$targetValue = A2( elm$json$Json$Decode$at, _List_fromArray( ['target', 'value']), elm$json$Json$Decode$string); var elm$html$Html$Events$onInput = function (tagger) { return A2( elm$html$Html$Events$stopPropagationOn, 'input', A2( elm$json$Json$Decode$map, elm$html$Html$Events$alwaysStop, A2(elm$json$Json$Decode$map, tagger, elm$html$Html$Events$targetValue))); }; var elm$html$Html$Events$alwaysPreventDefault = function (msg) { return _Utils_Tuple2(msg, true); }; var elm$virtual_dom$VirtualDom$MayPreventDefault = function (a) { return {$: 'MayPreventDefault', a: a}; }; var elm$html$Html$Events$preventDefaultOn = F2( function (event, decoder) { return A2( elm$virtual_dom$VirtualDom$on, event, elm$virtual_dom$VirtualDom$MayPreventDefault(decoder)); }); var elm$html$Html$Events$onSubmit = function (msg) { return A2( elm$html$Html$Events$preventDefaultOn, 'submit', A2( elm$json$Json$Decode$map, elm$html$Html$Events$alwaysPreventDefault, elm$json$Json$Decode$succeed(msg))); }; var author$project$Main$view = function (model) { if (model.loaded) { var count = elm$core$List$length(model.comments); var title = _Utils_ap( elm$core$String$fromInt(count), A2(author$project$Main$pluralize, ' Comentário', count)); return A2( elm$html$Html$div, _List_Nil, _List_fromArray( [ A2( elm$html$Html$h3, _List_Nil, _List_fromArray( [ elm$html$Html$text(title) ])), A2( elm$html$Html$ul, _List_fromArray( [ elm$html$Html$Attributes$class('list-unstyled') ]), A2(elm$core$List$map, author$project$Main$viewComment, model.comments)), A2( elm$html$Html$form, _List_fromArray( [ elm$html$Html$Events$onSubmit(author$project$Main$PostComment) ]), _List_fromArray( [ A2( elm$html$Html$div, _List_fromArray( [ elm$html$Html$Attributes$class('form-group') ]), _List_fromArray( [ A2( elm$html$Html$label, _List_Nil, _List_fromArray( [ elm$html$Html$text('Comentário:') ])), A2( elm$html$Html$input, _List_fromArray( [ elm$html$Html$Attributes$class('form-control'), elm$html$Html$Events$onInput(author$project$Main$UpdateAuthor), elm$html$Html$Attributes$value(model.form.author) ]), _List_Nil) ])), A2( elm$html$Html$div, _List_fromArray( [ elm$html$Html$Attributes$class('form-group') ]), _List_fromArray( [ A2( elm$html$Html$label, _List_Nil, _List_fromArray( [ elm$html$Html$text('Comentario:') ])), A2( elm$html$Html$textarea, _List_fromArray( [ elm$html$Html$Attributes$class('form-control'), elm$html$Html$Events$onInput(author$project$Main$UpdateContent), elm$html$Html$Attributes$value(model.form.content) ]), _List_Nil) ])), A2( elm$html$Html$button, _List_fromArray( [ elm$html$Html$Attributes$class('btn btn-primary') ]), _List_fromArray( [ elm$html$Html$text('Enviar') ])), A2( elm$html$Html$button, _List_fromArray( [ elm$html$Html$Attributes$class('btn btn-default') ]), _List_fromArray( [ elm$html$Html$text('Ressetar') ])) ])) ])); } else { return A2( elm$html$Html$h1, _List_Nil, _List_fromArray( [ elm$html$Html$text('Loading...') ])); } }; var elm$browser$Browser$External = function (a) { return {$: 'External', a: a}; }; var elm$browser$Browser$Internal = function (a) { return {$: 'Internal', a: a}; }; var elm$browser$Browser$Dom$NotFound = function (a) { return {$: 'NotFound', a: a}; }; var elm$core$Basics$never = function (_n0) { never: while (true) { var nvr = _n0.a; var $temp$_n0 = nvr; _n0 = $temp$_n0; continue never; } }; var elm$core$Task$Perform = function (a) { return {$: 'Perform', a: a}; }; var elm$core$Task$init = elm$core$Task$succeed(_Utils_Tuple0); var elm$core$Task$map = F2( function (func, taskA) { return A2( elm$core$Task$andThen, function (a) { return elm$core$Task$succeed( func(a)); }, taskA); }); var elm$core$Task$spawnCmd = F2( function (router, _n0) { var task = _n0.a; return _Scheduler_spawn( A2( elm$core$Task$andThen, elm$core$Platform$sendToApp(router), task)); }); var elm$core$Task$onEffects = F3( function (router, commands, state) { return A2( elm$core$Task$map, function (_n0) { return _Utils_Tuple0; }, elm$core$Task$sequence( A2( elm$core$List$map, elm$core$Task$spawnCmd(router), commands))); }); var elm$core$Task$onSelfMsg = F3( function (_n0, _n1, _n2) { return elm$core$Task$succeed(_Utils_Tuple0); }); var elm$core$Task$cmdMap = F2( function (tagger, _n0) { var task = _n0.a; return elm$core$Task$Perform( A2(elm$core$Task$map, tagger, task)); }); _Platform_effectManagers['Task'] = _Platform_createManager(elm$core$Task$init, elm$core$Task$onEffects, elm$core$Task$onSelfMsg, elm$core$Task$cmdMap); var elm$core$Task$command = _Platform_leaf('Task'); var elm$core$Task$perform = F2( function (toMessage, task) { return elm$core$Task$command( elm$core$Task$Perform( A2(elm$core$Task$map, toMessage, task))); }); var elm$core$String$length = _String_length; var elm$core$String$slice = _String_slice; var elm$core$String$dropLeft = F2( function (n, string) { return (n < 1) ? string : A3( elm$core$String$slice, n, elm$core$String$length(string), string); }); var elm$core$String$startsWith = _String_startsWith; var elm$url$Url$Http = {$: 'Http'}; var elm$url$Url$Https = {$: 'Https'}; var elm$core$String$indexes = _String_indexes; var elm$core$String$left = F2( function (n, string) { return (n < 1) ? '' : A3(elm$core$String$slice, 0, n, string); }); var elm$core$String$contains = _String_contains; var elm$core$String$toInt = _String_toInt; var elm$url$Url$Url = F6( function (protocol, host, port_, path, query, fragment) { return {fragment: fragment, host: host, path: path, port_: port_, protocol: protocol, query: query}; }); var elm$url$Url$chompBeforePath = F5( function (protocol, path, params, frag, str) { if (elm$core$String$isEmpty(str) || A2(elm$core$String$contains, '@', str)) { return elm$core$Maybe$Nothing; } else { var _n0 = A2(elm$core$String$indexes, ':', str); if (!_n0.b) { return elm$core$Maybe$Just( A6(elm$url$Url$Url, protocol, str, elm$core$Maybe$Nothing, path, params, frag)); } else { if (!_n0.b.b) { var i = _n0.a; var _n1 = elm$core$String$toInt( A2(elm$core$String$dropLeft, i + 1, str)); if (_n1.$ === 'Nothing') { return elm$core$Maybe$Nothing; } else { var port_ = _n1; return elm$core$Maybe$Just( A6( elm$url$Url$Url, protocol, A2(elm$core$String$left, i, str), port_, path, params, frag)); } } else { return elm$core$Maybe$Nothing; } } } }); var elm$url$Url$chompBeforeQuery = F4( function (protocol, params, frag, str) { if (elm$core$String$isEmpty(str)) { return elm$core$Maybe$Nothing; } else { var _n0 = A2(elm$core$String$indexes, '/', str); if (!_n0.b) { return A5(elm$url$Url$chompBeforePath, protocol, '/', params, frag, str); } else { var i = _n0.a; return A5( elm$url$Url$chompBeforePath, protocol, A2(elm$core$String$dropLeft, i, str), params, frag, A2(elm$core$String$left, i, str)); } } }); var elm$url$Url$chompBeforeFragment = F3( function (protocol, frag, str) { if (elm$core$String$isEmpty(str)) { return elm$core$Maybe$Nothing; } else { var _n0 = A2(elm$core$String$indexes, '?', str); if (!_n0.b) { return A4(elm$url$Url$chompBeforeQuery, protocol, elm$core$Maybe$Nothing, frag, str); } else { var i = _n0.a; return A4( elm$url$Url$chompBeforeQuery, protocol, elm$core$Maybe$Just( A2(elm$core$String$dropLeft, i + 1, str)), frag, A2(elm$core$String$left, i, str)); } } }); var elm$url$Url$chompAfterProtocol = F2( function (protocol, str) { if (elm$core$String$isEmpty(str)) { return elm$core$Maybe$Nothing; } else { var _n0 = A2(elm$core$String$indexes, '#', str); if (!_n0.b) { return A3(elm$url$Url$chompBeforeFragment, protocol, elm$core$Maybe$Nothing, str); } else { var i = _n0.a; return A3( elm$url$Url$chompBeforeFragment, protocol, elm$core$Maybe$Just( A2(elm$core$String$dropLeft, i + 1, str)), A2(elm$core$String$left, i, str)); } } }); var elm$url$Url$fromString = function (str) { return A2(elm$core$String$startsWith, 'http://', str) ? A2( elm$url$Url$chompAfterProtocol, elm$url$Url$Http, A2(elm$core$String$dropLeft, 7, str)) : (A2(elm$core$String$startsWith, 'https://', str) ? A2( elm$url$Url$chompAfterProtocol, elm$url$Url$Https, A2(elm$core$String$dropLeft, 8, str)) : elm$core$Maybe$Nothing); }; var elm$browser$Browser$element = _Browser_element; var elm$core$Platform$Sub$batch = _Platform_batch; var elm$core$Platform$Sub$none = elm$core$Platform$Sub$batch(_List_Nil); var author$project$Main$main = elm$browser$Browser$element( { init: author$project$Main$init, subscriptions: function (n) { return elm$core$Platform$Sub$none; }, update: author$project$Main$update, view: author$project$Main$view }); _Platform_export({'Main':{'init':author$project$Main$main( elm$json$Json$Decode$succeed(_Utils_Tuple0))(0)}});}(this));
export default (state = [], action) => { switch(action.type){ case 'GET_BOOKS_SUCCESS': return action.books; case 'CREATE_BOOK_SUCCESS': return state.concat(action.book); default: return state; } }
""" Dummy conftest.py for proyectoequipo1. If you don't know what this is for, just leave it empty. Read more about conftest.py under: - https://docs.pytest.org/en/stable/fixture.html - https://docs.pytest.org/en/stable/writing_plugins.html """ # import pytest
const fs = require('fs') const ApplicationController = require('./ApplicationController') const { AttachmentsService } = require('../Services') const { FileUploader } = require('../Uploaders') const { middleware } = require('@tetrajs/app') module.exports = class AttachmentsController extends ApplicationController { constructor() { super() const upload = new FileUploader('file') // Todo test validator. this.middlewares = [ { actions: [ middleware('require-authentication'), // multipart is not compatible csrf // security.csrf.protection, // security.csrf.token, this.setLocale, middleware('assets') ], }, { action: upload.process(), only: 'create', }, ] } async index(req, res, next) { const paginate = await AttachmentsService.fetchAttachments(req) res.render(req.adminIndexAttachmentsView, { title: 'attachments', paginate, errors: {}, }) } async show(req, res, next) { const attachment = await AttachmentsService.findById(req.params.id) const { content } = await attachment.getBuffer('original', true) if (!content) { res.writeHead(404) return res.end('File not found.') } res.setHeader('Content-Type', attachment.mimetype) res.writeHead(200) res.end(content) } async create(req, res, next) { const attachment = await AttachmentsService.createAttachment(req) const promise = attachment.save() promise.then(() => res.redirect(req.adminIndexAttachmentsPath())) promise.catch(async err => { const paginate = await AttachmentsService.fetchAttachments(req) if (req.xhr) { for (let key in err.errors) { if (err.errors.hasOwnProperty(key)) { res.status(400).send(res.__(err.errors[key].message)) } } } else { res.render(req.adminIndexAttachmentsView, { title: 'attachments', paginate, errors: err.errors, }) } }) } async deleteSelected(req, res, next) { try { for (let id of req.body.ids) { await AttachmentsService.deleteOne(id) } } catch (error) { res.status(400).json() } res.json() } }
import domdiv import domdiv.main from zipfile import ZipFile, ZIP_DEFLATED prefix = 'generated/sumpfork_dominion_tabs_' postfix = 'v' + domdiv.__version__ + '.pdf' def doit(args, main): args = args + ' --outfile ' + prefix + main + postfix args = args.split() fname = args[-1] print(args) print(':::Generating ' + fname) options = domdiv.main.parse_opts(args) options = domdiv.main.clean_opts(options) domdiv.main.generate(options) return fname argsets = [ ('', ''), ('--orientation=vertical', 'vertical_'), ('--papersize=A4', 'A4_'), ('--papersize=A4 --orientation=vertical', 'vertical_A4_'), ('--size=sleeved', 'sleeved_'), ('--size=sleeved --orientation=vertical', 'vertical_sleeved_') ] additional = ['--expansion-dividers'] fnames = [doit(args[0] + ' ' + ' '.join(additional), args[1]) for args in argsets] print(fnames) zip = ZipFile('generated/sumpfork_dominion_tabs_v' + domdiv.__version__ + '.zip', 'w', ZIP_DEFLATED) for f in fnames: zip.write(f) zip.close()
/** * Header */ var React = require('react'); var Header = React.createClass({ render: function() { return ( <header> <h2>Shinto</h2> </header> ); }, }); module.exports = Header;
const axios = require("axios"); const http = axios.create({ headers: { "Content-Type": "application/json", authorization: `APIKEY ${process.env.API_KEY}`, }, }); module.exports = http;
import React from "react" import { Row, Col, Container } from "react-bootstrap" import PropTypes from "prop-types" import { Parallax } from "react-parallax" const CtaTextRight = ({ cssClassName, text, image }) => ( <div className={cssClassName}> <Row noGutters={true} className="align-items-center grayBg"> <Col md={6}> <Parallax blur={0} bgImage={image} bgImageAlt="Capital Eight" strength={200} className="fullWidthImg" > <div style={{ height: 600 }} /> </Parallax> </Col> <Col md={6} className="textCol"> <Container className="align-middle"> <h2>{text.title}</h2> <p>{text.description}</p> </Container> </Col> </Row> </div> ) CtaTextRight.propTypes = { text: PropTypes.object, image: PropTypes.string, } CtaTextRight.defaultProps = { text: {}, image: ``, } export default CtaTextRight
/* global vars */ var result = 0; var displayVal = 0; /* assign actions to buttons and init calc */ { initClearEverything(); initDigits(); display(); function initDigits() { let digitButtons = document.getElementsByClassName("digit"); let len = digitButtons.length; //console.log("A"); for (i = 0; i < len; i++) { let num = digitButtons[i].textContent; //console.log("Adding listener to " + num); digitButtons[i].addEventListener("click", function () { pressed(num); }); } } function initClearEverything() { document.getElementById("ce").addEventListener("click", pushedCE); } } function pressed(num) { // let num = document.getElementById("7").textContent; //alert("Hello World! " + num); if(displayVal === 0) { displayVal = ""; } displayVal += num; display(); } function pushedCE() { // clear display displayVal = 0; result = 0; display(); } function display() { document.getElementById("result").textContent=displayVal; }
import React from 'react'; import { Layout } from 'components/theme/Layout'; const Page404 = () => ( <Layout> <h1>NOT FOUND</h1> <p>You just hit a route that doesn&#39;t exist... the sadness.</p> </Layout> ); export default Page404;
import React from 'react'; import PropTypes from 'prop-types'; import { makeStyles } from '@material-ui/core/styles'; import cx from 'classnames'; import { providePageContext, usePageContext } from './PageContext'; import InfoBar from './InfoBar'; import Header from './Header'; import Sidebar from './Sidebar'; import Body from './Body'; const useStyles = makeStyles(theme => ({ '@global': { body: { margin: 0, padding: 0, backgroundColor: theme.palette.background.default, }, a: { textDecoration: 'none', } }, root: { }, sidebarMargin: { marginLeft: theme.layout.SIDEBAR_WIDTH, transition: 'margin-left .3s', }, })); const Page = React.forwardRef(({ children, ...props }, ref) => { const pageContext = usePageContext(); const classes = useStyles(); React.useImperativeHandle(ref, () => pageContext); const { hasInfoBar, hasSidebar, hasHeader, screenType, sidebarIsVisible, } = pageContext; return ( <> <div className={cx(classes.root, { [classes.sidebarMargin]: sidebarIsVisible && (screenType === 'desktop'), })} > {hasInfoBar && <InfoBar />} {hasHeader && <Header />} {hasSidebar && <Sidebar />} <Body {...props}>{children}</Body> </div> </> ); }); Page.propTypes = { children: PropTypes.node, }; export default providePageContext(Page);
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ module.exports = { parser: '@typescript-eslint/parser', // Specifies the ESLint parser extends: [ 'airbnb-base', 'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier 'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. ], plugins: ['@typescript-eslint'], parserOptions: { ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features sourceType: 'module', // Allows for the use of imports }, rules: { 'import/extensions': ['error', 'ignorePackages', { ts: 'never' }], 'no-console': ['warn', { allow: ['log', 'error'] }], 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': 'error', 'no-useless-constructor': 'off', '@typescript-eslint/no-useless-constructor': 'error', 'no-empty-function': 'off', '@typescript-eslint/no-empty-function': 'error', 'import/no-extraneous-dependencies': ['error', {'devDependencies': ['**/*.test.ts', 'integration-tests/*']}], 'no-shadow': 'off', // replaced by ts-eslint rule below '@typescript-eslint/no-shadow': 'error' }, settings: { 'import/resolver': { node: { extensions: ['.ts'], }, }, }, env: { jest: true, }, };
from math import hypot from ..Qt import QtCore, QtGui, QtWidgets, mkQApp __all__ = ['JoystickButton'] class JoystickButton(QtWidgets.QPushButton): sigStateChanged = QtCore.Signal(object, object) ## self, state def __init__(self, parent=None): QtWidgets.QPushButton.__init__(self, parent) self.radius = 200 self.setCheckable(True) self.state = None self.setState(0, 0) self.setFixedWidth(50) self.setFixedHeight(50) def mousePressEvent(self, ev): self.setChecked(True) lpos = ev.position() if hasattr(ev, 'position') else ev.localPos() self.pressPos = lpos ev.accept() def mouseMoveEvent(self, ev): lpos = ev.position() if hasattr(ev, 'position') else ev.localPos() dif = lpos - self.pressPos self.setState(dif.x(), -dif.y()) def mouseReleaseEvent(self, ev): self.setChecked(False) self.setState(0,0) def wheelEvent(self, ev): ev.accept() def doubleClickEvent(self, ev): ev.accept() def getState(self): return self.state def setState(self, *xy): xy = list(xy) d = hypot(xy[0], xy[1]) # length nxy = [0, 0] for i in [0,1]: if xy[i] == 0: nxy[i] = 0 else: nxy[i] = xy[i] / d if d > self.radius: d = self.radius d = (d / self.radius) ** 2 xy = [nxy[0] * d, nxy[1] * d] w2 = self.width() / 2 h2 = self.height() / 2 self.spotPos = QtCore.QPoint( int(w2 * (1 + xy[0])), int(h2 * (1 - xy[1])) ) self.update() if self.state == xy: return self.state = xy self.sigStateChanged.emit(self, self.state) def paintEvent(self, ev): super().paintEvent(ev) p = QtGui.QPainter(self) p.setBrush(QtGui.QBrush(QtGui.QColor(0,0,0))) p.drawEllipse( self.spotPos.x() - 3, self.spotPos.y() - 3, 6, 6 ) def resizeEvent(self, ev): self.setState(*self.state) super().resizeEvent(ev) if __name__ == '__main__': app = mkQApp() w = QtWidgets.QMainWindow() b = JoystickButton() w.setCentralWidget(b) w.show() w.resize(100, 100) def fn(b, s): print("state changed:", s) b.sigStateChanged.connect(fn) app.exec() if hasattr(app, 'exec') else app.exec_()
import SubMenu from './SubMenu'; import SubMenuItem from './SubMenuItem'; export { SubMenuItem }; export default SubMenu;
if (typeof process !== 'undefined' && parseInt(process.versions.node.split('.')[0]) < 14) { console.error('Your node version is currently', process.versions.node) console.error('Please update it to a version >= 14.x.x from https://nodejs.org/') process.exit(1) } module.exports = require('./lib/loader.js')
var gitblog = function(config) { var self = this; self.getUrlParam = function(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return decodeURI(r[2]); return null; } self.options = { id: null, label: null, q: null, page: 1, token: null, code: null, redirect_url: null, } self.set = function() { if (self.getUrlParam('id') != undefined) { self.options.id = parseInt(self.getUrlParam('id')); } if (self.getUrlParam('label') != undefined) { self.options.label = self.getUrlParam('label'); } if (self.getUrlParam('q') != undefined) { self.options.q = self.getUrlParam('q'); } if (self.getUrlParam('page') != undefined) { self.options.page = parseInt(self.getUrlParam('page')); } if (self.getUrlParam('access_token') != undefined) { self.options.token = self.getUrlParam('access_token'); } if (self.getUrlParam('code') != undefined) { self.options.code = self.getUrlParam('code'); } if (self.getUrlParam('state') != undefined) { self.options.redirect_url = self.getUrlParam('state'); } if (self.options.code != null && self.options.redirect_url != null) { window.location.href = config.server_link + "?code=" + self.options.code + "&redirect_url=" + self.options.redirect_url + "&client_id=" + config.client_id + "&client_secret=" + config.client_secret; } } self.set(); self.utc2localTime = function(time) { var time_string_utc_epoch = Date.parse(time); var unixTimestamp = new Date(time_string_utc_epoch); var year = unixTimestamp.getFullYear(); var month = unixTimestamp.getMonth() + 1; var date = unixTimestamp.getDate(); var hour = unixTimestamp.getHours(); var minute = unixTimestamp.getMinutes(); var second = unixTimestamp.getSeconds(); hour = (hour<10)?'0'+hour:hour; minute = (minute<10)?'0'+minute:minute; second = (second<10)?'0'+second:second; return year+'年'+month+'月'+date+'日'+' '+hour+':'+minute+':'+second; } String.prototype.replaceAll = function(a, b) { return this.replace(new RegExp(a, 'gm'), b); } var Info = function() { this.title = config.title; this.instruction = config.instruction; } Info.prototype.init = function() { $('#title').text(this.title); $('#instruction').text(this.instruction); document.getElementsByTagName("title")[0].innerText = this.title; } var Menu = function() { this.labels = []; } Menu.prototype = { searchOnblur: function() { if ($('.search-input').val() == "") { $(".search-input").css("width", '42px'); $(".search-input").css("z-index", -1); } }, show: function() { var menu = this; for(var name in config.menu) { document.getElementById("menu").innerHTML += '<li><a href=' + config.menu[name] + '><span>' + name + '</span></a></li>'; } if (Object.keys(config.friends).length != 0) { var menu_friend = document.getElementById("friends"); menu_friend.innerHTML = '<li><text style="font-zise:14px"><span style="color: white;transform:translateX(4px)">友链:</span></text></li>'; for (var name in config.friends) { menu_friend.innerHTML += '<li><a href=' + config.friends[name] + ' target="_blank"><span>' + name + '</span></a></li>'; } } $(".search-input").on("blur", function() { menu.searchOnblur(); }); } } var Icon = function(options, name, left) { this.icon_src = options.icon_src; this.href = options.href; this.hidden_img = options.hidden_img; this.width = options.width; this.name = name; this.position = left; } Icon.prototype = { init: function() { var icon = this; if(icon.href != undefined && icon.href != null) { document.getElementById("div_"+icon.name).innerHTML += '<a target="_blank" title="' + icon.name + '" id="icon_' + icon.name + '" href="' + icon.href + '"><img src="' + icon.icon_src + '" style="width:50px;margin-left:10px;margin-right:10px"></a>'; } else { document.getElementById("div_"+icon.name).innerHTML += '<img src="' + icon.icon_src + '" title="' + icon.name + '" id="icon_' + icon.name + '" style="width:50px;margin-left:10px;margin-right:10px;cursor:pointer">'; } if (icon.hidden_img != undefined && icon.hidden_img != null) { document.getElementById("div_"+icon.name).innerHTML += '<img id="' + icon.name + '" src="' + icon.hidden_img + '" style="width: ' + icon.width + 'px; position: absolute; left: calc(50% - ' + this.position + 'px); bottom: 180px; transition: all 0.3s ease 0s; box-shadow: rgb(149, 165, 166) 0px 0px 5px; transform: translateY(-20px); z-index: -1; opacity: 0">'; $('#icon_' + icon.name).mouseover(function() { icon.changeIcon(icon.name, 'show'); }); $('#icon_' + icon.name).mouseout(function() { icon.changeIcon(icon.name, 'hidden'); }); } }, changeIcon: function(id, action) { if (action == 'show') { $('#' + id).css('z-index', '99'); $('#' + id).css("opacity", "1"); $('#' + id).css("transform", "translateY(0)"); } else if (action == 'hidden') { $('#' + id).css('z-index', '-1'); $('#' + id).css("opacity", "0"); $('#' + id).css("transform", "translateY(-20px)"); } } } var Footer = function() { this.page = new Pages(); this.icons = []; this.icon_num = 0; this.content = 'Powered by <a href="https://github.com/imuncle/gitblog" target="_blank" style="color: aquamarine;text-decoration:none;border-bottom: 1px solid #79f8d4;">gitblog</a>'; } Footer.prototype = { showIcon: function() { var footer = this; for (var i in config.icons) { if (config.icons[i].icon_src != undefined && config.icons[i].icon_src != null) { document.getElementById('icon').innerHTML += '<div style="padding-inline-start: 0;margin: 0" id="div_'+i+'"></div>'; } } for (var i in config.icons) { if (config.icons[i].icon_src != undefined && config.icons[i].icon_src != null) { var left = Object.keys(config.icons).length * 35 - 70 * footer.icon_num + config.icons[i].width / 2 - 35; var icon = new Icon(config.icons[i], i, left); icon.init(); footer.icons.push(icon); footer.icon_num++; } } }, show: function() { document.getElementById('footer').innerHTML += this.content; this.showIcon(); } } var Pages = function() { this.page = 1; this.pages = 1; this.itemNum = 0; this.pageLimit = 7; } Pages.prototype = { getNum: function(request_url) { var page = this; if (self.options.page != null && self.options.page != undefined) { page.page = self.options.page; } $.ajax({ type: 'get', url: request_url, success: function(data) { if (self.options.label != null && self.options.label != undefined) { page.itemNum = data.length; } else if(self.options.q != null && self.options.q != undefined) { page.itemNum = data.total_count; } else if (self.options.id != null && self.options.id != undefined) { page.itemNum = data.length; document.getElementById('comments-num').innerHTML = page.itemNum; } else { page.itemNum = data.open_issues_count; } if (page.itemNum > 10) { page.pages = Math.ceil(page.itemNum / 10); page.show(); } } }); }, show: function() { var page = this; $('#pages').css('display', 'inline-block'); document.getElementById('pages').innerHTML = '<li id="last_page"><a id="last" style="cursor: pointer">«</a></li>'; if (page.pages <= page.pageLimit) { for (var i = 1; i <= page.pages; i++) { document.getElementById('pages').innerHTML += '<li><a id="page' + i + '" style="cursor:pointer">' + i + '</a></li>'; } } else { if (page.page >= 5) { document.getElementById('pages').innerHTML += '<li><a id="page1" style="cursor:pointer">1</a></li>'; document.getElementById('pages').innerHTML += '<li><a style="cursor:pointer;pointer-events: none;">...</a></li>'; document.getElementById('pages').innerHTML += '<li><a id="page' + (page.page - 1) + '" style="cursor:pointer">' + (page.page - 1) + '</a></li>'; document.getElementById('pages').innerHTML += '<li><a id="page' + page.page + '" style="cursor:pointer">' + page.page + '</a></li>'; } else { for (var i = 1; i <= page.page; i++) { document.getElementById('pages').innerHTML += '<li><a id="page' + i + '" style="cursor:pointer">' + i + '</a></li>'; } } if (page.page <= page.pages - 4) { document.getElementById('pages').innerHTML += '<li><a id="page' + (page.page + 1) + '" style="cursor:pointer">' + (page.page + 1) + '</a></li>'; document.getElementById('pages').innerHTML += '<li><a style="cursor:pointer;pointer-events: none;">...</a></li>'; document.getElementById('pages').innerHTML += '<li><a id="page' + page.pages + '" style="cursor:pointer">' + page.pages + '</a></li>'; } else { for (var i = page.page + 1; i <= page.pages; i++) { document.getElementById('pages').innerHTML += '<li><a id="page' + i + '" style="cursor:pointer">' + i + '</a></li>'; } } } document.getElementById('pages').innerHTML += '<li id="next_page"><a id="next" style="cursor: pointer">»</a></li>'; for (var i = 1; i <= page.pages; i++) { if (self.options.label != undefined) { $('#page' + i).click(function() { window.location.href = "?label=" + self.options.label + "&page=" + this.innerHTML; }); } else if (self.options.id != undefined) { $('#page' + i).click(function() { window.location.href = "?id=" + self.options.id + "&page=" + this.innerHTML; }); } else if(self.options.q != undefined) { $('#page' + i).click(function() { window.location.href = "?q=" + self.options.q + "&page=" + this.innerHTML; }); } else { $('#page' + i).click(function() { window.location.href = "?page=" + this.innerHTML; }); } if (i == page.page) { $('#page' + i).addClass('active'); } else { $('#page' + i).removeClass('active'); } } if (page.page == 1) { $('#last_page').css('pointer-events', 'none'); $('#next_page').css('pointer-events', 'auto'); } else if (page.page == page.pages) { $('#last_page').css('pointer-events', 'auto'); $('#next_page').css('pointer-events', 'none'); } document.getElementById('last').onclick = function() { page.last(); } document.getElementById('next').onclick = function() { page.next(); } }, last: function() { this.page--; if (self.options.label != undefined) { window.location.href = '?label=' + self.options.label + '&page=' + this.page; } else if (self.options.id != undefined && self.options.id != null) { window.location.href = '?id=' + self.options.id + '&page=' + this.page; } else { window.location.href = '?page=' + this.page; } }, next: function() { this.page++; if (self.options.label != undefined) { window.location.href = '?label=' + self.options.label + '&page=' + this.page; } else if (self.options.id != undefined && self.options.id != null) { window.location.href = '?id=' + self.options.id + '&page=' + this.page; } else { window.location.href = '?page=' + this.page; } } } var Reaction = function() { this.num = 0; this.isLike = false; } Reaction.prototype = { like: function(type, id) { var reaction = this; if (reaction.isLike == true) return; if (window.localStorage.access_token == undefined || window.localStorage.access_token == null) { alert("请先登录!"); return; } var request_url = ''; if (type == 'issue') { request_url = 'https://api.github.com/repos/' + config.name + '/' + config.repo + '/issues/' + id + '/reactions'; } else if (type == 'comment') { request_url = 'https://api.github.com/repos/' + config.name + '/' + config.repo + '/issues/comments/' + id + '/reactions'; } $.ajax({ type: "post", url: request_url, headers: { Authorization: 'token ' + window.localStorage.access_token, Accept: 'application/vnd.github.squirrel-girl-preview+json' }, data: JSON.stringify({ "content": "heart" }), success: function() { reaction.num += 1; reaction.isLike = true; reaction.show(type, id); } }); }, getNum: function(type, id) { var reaction = this; var request_url = ''; if (type == 'issue') { request_url = 'https://api.github.com/repos/' + config.name + '/' + config.repo + '/issues/' + id + '/reactions'; } else if (type == 'comment') { request_url = 'https://api.github.com/repos/' + config.name + '/' + config.repo + '/issues/comments/' + id + '/reactions'; } $.ajax({ type: "get", url: request_url + '?content=heart', headers: { Accept: 'application/vnd.github.squirrel-girl-preview+json' }, success: function(data) { for (var i in data) { if (data[i].user.login == window.localStorage.name) { reaction.isLike = true; } } reaction.num = data.length; reaction.show(type, id); } }); }, show: function(type, id) { var reaction = this; if (reaction.isLike == false) { document.getElementById(id).innerHTML = '<img src="images/heart.svg" style="height:20px;float:left">'; } else if (reaction.isLike == true) { document.getElementById(id).innerHTML = '❤️'; } document.getElementById(id).innerHTML += reaction.num; document.getElementById(id).onclick = function() { reaction.like(type, id); }; } } var commentItem = function() { this.reaction = new Reaction(); } var Comment = function() { this.login = false; this.item = []; } Comment.prototype = { send: function() { var comment = this; var input = document.getElementById('comment-input').value; var access_token = window.localStorage.access_token; $.ajax({ type: "post", url: 'https://api.github.com/repos/' + config.name + '/' + config.repo + '/issues/' + self.options.id + '/comments', headers: { Authorization: 'token ' + access_token, Accept: 'application/vnd.github.squirrel-girl-preview, application/vnd.github.html+json', 'Content-Type': 'application/json' }, data: JSON.stringify({ "body": input }), dataType: "json", success: function(data) { if (data.id != undefined) { document.getElementById('comment-input').value = ""; comment.addComment(data); document.getElementById('comments-num').innerHTML++; } } }); }, init: function() { var comment = this; comment.checkIsLogin(); $.ajax({ type: 'get', headers: { Accept: 'application/vnd.github.squirrel-girl-preview, application/vnd.github.html+json, application/x-www-form-urlencoded', }, url: 'https://api.github.com/repos/' + config.name + '/' + config.repo + '/issues/' + self.options.id + '/comments?page=' + self.options.page + '&per_page=10', success: function(data) { document.getElementById('comment-list').innerHTML = ""; for (var i in data) { comment.addComment(data[i]); } } }); var login = document.getElementById('login'); if (comment.login == false) { login.innerHTML = '<a class="gitment-editor-login-link" id="log">登入</a> with GitHub'; } else { login.innerHTML = '<a class="gitment-editor-login-link" id="log">登出</a>'; } document.getElementById('log').onclick = function() { if (comment.login == false) { comment.log(); } else { comment.logout(); } } var editor_content = document.getElementById('write-field'); if (comment.login == false) { editor_content.innerHTML = '<textarea placeholder="(发表评论)" title="请登入以发表评论" disabled id="comment-input"></textarea>'; $('.gitment-editor-submit').attr("disabled", true); } else { editor_content.innerHTML = '<textarea placeholder="(发表评论)" id="comment-input"></textarea>'; $('.gitment-editor-submit').attr("disabled", false); } $('#editComment').click(function() { comment.edit(); }); $('#preview').click(function() { comment.preview(); }); $('.gitment-editor-submit').click(function() { comment.send(); }); }, addComment: function(data) { var comment = new commentItem(); data.created_at = self.utc2localTime(data.created_at); document.getElementById('comment-list').innerHTML += '<li class="gitment-comment">' + '<a class="gitment-comment-avatar" href=' + data.user.html_url + ' target="_blank">' + '<img class="gitment-comment-avatar-img" src=' + data.user.avatar_url + '></a>' + '<div class="gitment-comment-main"><div class="gitment-comment-header">' + '<a class="gitment-comment-name" href=' + data.user.html_url + ' target="_blank">' + data.user.login + '</a> 评论于 ' + '<span>' + data.created_at + '</span>' + '<div style="float:right;cursor:pointer" id="' + data.id + '"></div>' + '</div><div class="gitment-comment-body gitment-markdown">' + data.body_html + '</div></div>'; comment.reaction.getNum('comment', data.id); this.item.push(comment); }, checkIsLogin: function() { var comment = this; if (window.localStorage.access_token != undefined) { this.login = true; } var avatar = document.getElementById('avatar'); if (this.login == true) { $.ajax({ type: "get", async: false, url: 'https://api.github.com/user?access_token=' + window.localStorage.access_token, success: function(data) { window.localStorage.setItem('user_avatar_url', data.avatar_url); window.localStorage.setItem('user_url', data.html_url); window.localStorage.setItem('name', data.login); avatar.innerHTML = '<a class="gitment-comment-avatar" href=' + window.localStorage.user_url + ' target="_blank">' + '<img class="gitment-comment-avatar-img" src=' + window.localStorage.user_avatar_url + '></a>'; }, error: function() { console.log("用户信息过期,退出登录状态"); comment.logout(); } }); } else { avatar.innerHTML = '<a class="gitment-editor-avatar" id="gitment-avatar" title="login with GitHub">' + '<img src="images/gitment-github-icon.svg" class="gitment-github-icon" style="width:44px">' + '</a></div>'; document.getElementById('gitment-avatar').onclick = function() { comment.log(); } } }, preview: function() { $('#editComment').removeClass('gitment-selected'); $('#preview').addClass('gitment-selected'); $('.gitment-editor-write-field').addClass('gitment-hidden'); $('.gitment-editor-preview-field').removeClass('gitment-hidden'); var preview_content = document.getElementById('preview-content'); var comment_input = document.getElementById('comment-input').value; if (comment_input == "") { preview_content.innerHTML = '(没有预览)'; } else { preview_content.innerHTML = '预览加载中'; $.ajax({ type: "post", url: 'https://api.github.com/markdown', headers: { Accept: 'text/html, application/vnd.github.squirrel-girl-preview, application/vnd.github.html+json, application/x-www-form-urlencoded', 'Content-Type': 'text/html' }, data: JSON.stringify({ mode: 'gfm', text: comment_input }), dataType: "text/html", success: function(message) { preview_content.innerHTML = message.responseText; }, error: function(message) { preview_content.innerHTML = message.responseText; } }); } }, edit: function() { $('#editComment').addClass('gitment-selected'); $('#preview').removeClass('gitment-selected'); $('.gitment-editor-write-field').removeClass('gitment-hidden'); $('.gitment-editor-preview-field').addClass('gitment-hidden'); }, log: function() { window.location.href = 'https://github.com/login/oauth/authorize?client_id=' + config.client_id + '&scope=public_repo&state=' + window.location.href; }, logout: function() { this.login = false; window.localStorage.clear(); this.init(); } } var Article = function() { this.comments = new Comment(); this.page = new Pages(); this.reaction = new Reaction(); this.comment_url = ""; } Article.prototype = { init: function() { var article = this; if (self.options.token != undefined && self.options.token != null) { window.localStorage.clear(); window.localStorage.setItem("access_token", self.options.token); history.replaceState(null, config.title, 'content.html?id=' + self.options.id); } article.comment_url = 'https://api.github.com/repos/' + config.name + '/' + config.repo + '/issues/' + self.options.id + '/comments'; article.page.getNum(article.comment_url); $.ajax({ type: 'get', headers: { Accept: 'application/vnd.github.squirrel-girl-preview, application/vnd.github.html+json, application/x-www-form-urlencoded', }, url: 'https://api.github.com/repos/' + config.name + '/' + config.repo + '/issues/' + self.options.id, success: function(data) { document.getElementById('title').innerHTML = data.title; document.getElementsByTagName("title")[0].innerText = data.title + "-" + config.title; data.created_at = self.utc2localTime(data.created_at); document.getElementById('instruction').innerHTML = data.created_at; document.getElementById('content').innerHTML = data.body_html; var labels = document.getElementById('labels'); for (var i in data.labels) { labels.innerHTML += '<a href="issue_per_label.html?label=' + data.labels[i].name + '"># ' + data.labels[i].name + '</a>'; } labels.innerHTML += '<div style="float:right;cursor:pointer" id="' + self.options.id + '"></div>'; article.comments.init(); article.reaction.getNum('issue', self.options.id); } }); } } var Issue = function() { this.issue_url = ''; this.issue_perpage_url = ''; this.issue_search_url = ''; this.page = new Pages(); } Issue.prototype = { getTags: function() { $.ajax({ type: 'get', url: 'https://api.github.com/repos/' + config.name + '/' + config.repo + '/labels', success: function(data) { for (var i in data) { document.getElementById('tags').innerHTML += '<a href="issue_per_label.html?label=' + data[i].name + '">' + data[i].name + '</a>'; } }, }); }, addItem: function(data) { document.getElementById('issue-list').innerHTML = ''; for (var i in data) { var labels_content = ''; for (var j in data[i].labels) { labels_content += '<li><a href=issue_per_label.html?label=' + data[i].labels[j].name + '>' + data[i].labels[j].name + '</a></li>'; } data[i].body = data[i].body.replace(/<.*?>/g, ""); data[i].created_at = self.utc2localTime(data[i].created_at); document.getElementById('issue-list').innerHTML += '<li><p class="date">' + data[i].created_at + '</p><h4 class="title"><a href="content.html?id=' + data[i].number + '">' + data[i].title + '</a></h4><div class="excerpt"><p class="issue">' + data[i].body + '</p></div>' + '<ul class="meta"><li>' + data[i].user.login + '</li>' + labels_content + '</ul></li>'; } }, show: function(request_url) { var issue = this; $.ajax({ type: 'get', url: request_url + 'page=' + self.options.page + '&per_page=10', success: function(data) { if (self.options.q == undefined || self.options.q == null) { if (data.length == 0) { document.getElementById('issue-list').innerHTML = '这个人很勤快但这里什么都还没写~'; $('.footer').css('position', 'absolute'); } else { issue.addItem(data); } } else { if (data.items.length == 0) { window.location.href = '404.html'; } else { issue.addItem(data.items); } var html = document.getElementById('issue-list').innerHTML; var newHtml; if(self.options.q != '') newHtml = html.replaceAll(self.options.q, '<font style="background-color:yellow;">' + self.options.q + '</font>'); else newHtml = html; document.getElementById('issue-list').innerHTML = newHtml; } } }); }, init: function() { if (self.options.label == undefined) { if (self.options.q == undefined) { this.issue_url = 'https://api.github.com/repos/' + config.name + '/' + config.repo; this.issue_perpage_url = 'https://api.github.com/repos/' + config.name + '/' + config.repo + '/issues?creator=' + config.name + '&'; } else { this.search(self.options.q); } } else { this.issue_url = 'https://api.github.com/repos/' + config.name + '/' + config.repo + '/issues?labels=' + self.options.label; this.issue_perpage_url = 'https://api.github.com/repos/' + config.name + '/' + config.repo + '/issues?creator=' + config.name + '&labels=' + self.options.label + '&'; document.getElementById('title').innerHTML = self.options.label; $.ajax({ type: 'get', headers: { Accept: 'application/vnd.github.symmetra-preview+json', }, url: 'https://api.github.com/repos/' + config.name + '/' + config.repo + '/labels/' + self.options.label, success: function(data) { document.getElementById('instruction').innerHTML = data.description; } }); } this.page.getNum(this.issue_url); this.show(this.issue_perpage_url); this.getTags(); }, search: function(search) { search = encodeURI(search); this.issue_url = 'https://api.github.com/search/issues?q=' + search + ' author:' + config.name + '+in:title,body+repo:' + config.name + '/' + config.repo; this.issue_perpage_url = 'https://api.github.com/search/issues?q=' + search + ' author:' + config.name + '+in:title,body+repo:' + config.name + '/' + config.repo + '&'; } } var Buttons = function() {} Buttons.prototype = { getByClass: function(Parent, Class){ var result=[]; var ele=Parent.getElementsByTagName('*'); for(var i=0;i<ele.length;i++){ if(ele[i].className==Class) { result.push(ele[i]); } } return result; }, init: function() { $('.navi-button').click(function() { if ($('.main').css("transform") == "matrix(1, 0, 0, 1, 0, 0)") { $('.main').css("transform", "translateX(-150px)"); $('.main-navication span').css("opacity", "1"); $('.main-navication').css("opacity", "1"); $('.main-navication span').css("transform", "translateX(-10px)"); $('.navi-button').css("transform", "translateX(-150px)"); $('.Totop').css("transform", "translateX(-150px)"); $('.search').css("transform", "translateX(-150px)"); $('.search-input').css("transform", "translateX(-150px)"); } }); this.getByClass(document.getElementsByTagName("body")[0], "main")[0].addEventListener("mousedown",function(){ if($('.main').css("transform") != "matrix(1, 0, 0, 1, 0, 0)") { $('.main').css("transform", "translateX(0)"); $('.main-navication span').css("opacity", "0"); $('.main-navication').css("opacity", "0"); $('.main-navication span').css("transform", "translateX(-50px)"); $('.navi-button').css("transform", "translateX(0px)"); $('.Totop').css("transform", "translateX(0px)"); $('.search').css("transform", "translateX(0px)"); $('.search-input').css("transform", "translateX(0px)"); } },false); $('.Totop').click(function() { $('html,body').animate({ scrollTop: '0px' }, 600); }); $('.search').click(function() { $(".search-input").css('z-index', 99); $(".search-input").css("width", '300px'); $(".search-input").focus(); }); $('.search-input').bind('keypress', function(event) { if (event.keyCode == "13" && $('.search-input').val() != "") { window.location.href = 'issue_per_label.html?q=' + $('.search-input').val(); } }) window.onscroll = function() { if ($(document).scrollTop() >= 0.6 * document.documentElement.clientHeight) { $('.Totop').css('opacity', 1); } else { $('.Totop').css('opacity', 0); } } } } self.init = function() { self.info = new Info(); self.info.init(); if (self.options.id != null && self.options.id != undefined) { self.content = new Article(); self.content.init(); } else { self.content = new Issue(); self.content.init(); } self.menu = new Menu(); self.menu.show(); self.footer = new Footer(); self.footer.show(); self.button = new Buttons(); self.button.init(); } console.log('\n' + ' %c Gitblog' + ' %c https://github.com/imuncle/gitblog \n', 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;'); } $.ajax({ type: 'get', headers: { Accept: 'application/json', }, url: 'config.json', success: function(data) { new gitblog(data).init(); } });
#!/usr/bin/env python3 '''Benchmark Astropy's LS fast_impl versus a baseline C++ implementation ''' import timeit import numpy as np from astropy.timeseries.periodograms.lombscargle.implementations import fast_impl import threadpoolctl # don't let numpy do multithreading behind our back! _limiter = threadpoolctl.threadpool_limits(1) rand = np.random.default_rng(43) # The Gowanlock+ paper uses N_t=3554 as their single-object dataset. # N_f=10**5 is a typical number of freq bins (we call this M) N = 3554 dtype = np.float64 df = dtype(0.1) M = 10**5 # Generate fake data random = np.random.default_rng(5043) t = np.sort(random.uniform(0, 10, N).astype(dtype)) y = random.normal(size=N).astype(dtype) dy = random.uniform(0.5, 2.0, N).astype(dtype) # And some derived quantities w = dy**-2. w /= w.sum() # for now, the C++ code will require normalized w f0 = dtype(df/2) # f0=0 yields power[0] = nan. let's use f0=df/2, from LombScargle.autofrequency print(f'Running with {N=}, {M=}, dtype {dtype.__name__}') if do_nufft:=True: import nufft_ls.cpu nufft_ls_compute = {np.float32: nufft_ls.cpu.baseline_compute_float, np.float64: nufft_ls.cpu.baseline_compute, }[dtype] # static void compute(size_t N, const Scalar* t, const Scalar* y, const Scalar* w, size_t M, # const Scalar f0, const Scalar df, Scalar* power); power = np.zeros(M, dtype=y.dtype) nufft_ls_compute(t, y, w, f0, df, power) time = timeit.timeit('nufft_ls_compute(t, y, w, f0, df, power)', number=(nloop:=3), globals=globals(), ) print(f'baseline took {time/nloop:.4g} sec') if do_astropy:=True: # N.B. we are using a patched astropy that will do the computation in float32 if requested apower = fast_impl.lombscargle_fast(t, y, dy=dy, f0=f0, df=df, Nf=M, use_fft=False, center_data=False, fit_mean=False) atime = timeit.timeit('fast_impl.lombscargle_fast(t, y, dy=dy, f0=f0, df=df, Nf=M, use_fft=False, center_data=False, fit_mean=False)', number=(nloop:=1), globals=globals(), ) print(f'astropy took {atime/nloop:.4g} sec') if dtype == np.float32: isclose = lambda *args: np.isclose(*args, rtol=1e-4, atol=1e-7) else: isclose = lambda *args: np.isclose(*args) if do_nufft and do_astropy: # currently these don't match exactly in float32, even with the relaxed tolerance print(f'frac isclose {isclose(power, apower).mean()*100:.4g}%') print(f'max frac err {(np.abs(power-apower)/apower).max():.4g}') #breakpoint()
import Icon from 'vue-awesome/components/Icon' Icon.register({ notifications_off_outlined: { paths: [ { d: 'M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2zm0-15.5c2.49 0 4 2.02 4 4.5v.1l2 2V11c0-3.07-1.63-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68c-.24.06-.47.15-.69.23l1.64 1.64c.18-.02.36-.05.55-.05z' }, { d: 'M5.41 3.35L4 4.76l2.81 2.81C6.29 8.57 6 9.74 6 11v5l-2 2v1h14.24l1.74 1.74 1.41-1.41L5.41 3.35zM16 17H8v-6c0-.68.12-1.32.34-1.9L16 16.76V17z' } ], width: '24', height: '24' } })
qtd_km = float(input('Quantos KM vc percorreu? ')) qtd_dias = int(input("Quantos dias vc passou com o carro? ")) custo = 60*qtd_dias + 0.15*qtd_km print('O valor total a ser pago é de R${:.2f}'.format(custo))
// app.settings.js // node modules require('dotenv').config(); const path = require('path'); // settings module.exports = { alias: { '@': path.resolve('../src/assetbundles/seomatic/src'), }, copyright: '©2020 nystudio107.com', entry: { 'dashboard': '@/js/dashboard.js', 'content-seo': '@/js/content-seo.js', 'seomatic': '@/js/seomatic.js', 'seomatic-meta': '@/js/seomatic-meta.js', 'seomatic-tokens': '@/js/seomatic-tokens.js', 'twig-editor': '@/js/twig-editor.js', 'javascript-editor': '@/js/javascript-editor.js', }, extensions: ['.ts', '.js', '.vue', '.json'], name: 'seomatic', paths: { dist: path.resolve('../src/assetbundles/seomatic/dist/'), }, urls: { publicPath: () => process.env.PUBLIC_PATH || '', }, };
import pygame import sys from pygame.locals import * pygame.init() screen = pygame.display.set_mode((640, 480)) pygame.mouse.set_visible(0) while True: for event in pygame.event.get(): if event.type == QUIT: sys.exit() if event.type == MOUSEMOTION: print("Mouse: (%d, %d)" % event.pos)
import React, {Component} from 'react'; import {Platform, StyleSheet, Text, View,Button,WebView} from 'react-native'; import PublicDefine from "./PublicDefine"; export default class Job extends Component { constructor(props) { super(props); this.state = { url: 'https://www.qq.com/', canGoBack: false, } } render() { const {navigation} = this.props; return ( <View style={styles.container}> <WebView ref='wb' automaticallyAdjustContentInsets={false} style={{width:PublicDefine.width,height:PublicDefine.height-98}} source={{uri: this.state.url}} javaScriptEnabled={true} domStorageEnabled={true} decelerationRate="normal" startInLoadingState={true} /> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, });
/* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; export function elasticsearchMetricsSpecProvider(server, context) { const moduleName = 'elasticsearch'; return { id: 'elasticsearchMetrics', name: i18n.translate('kbn.server.tutorials.elasticsearchMetrics.nameTitle', { defaultMessage: 'Elasticsearch metrics', }), isBeta: false, category: TUTORIAL_CATEGORY.METRICS, shortDescription: i18n.translate('kbn.server.tutorials.elasticsearchMetrics.shortDescription', { defaultMessage: 'Fetch internal metrics from Elasticsearch.', }), longDescription: i18n.translate('kbn.server.tutorials.elasticsearchMetrics.longDescription', { defaultMessage: 'The `elasticsearch` Metricbeat module fetches internal metrics from Elasticsearch. \ [Learn more]({learnMoreLink}).', values: { learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-elasticsearch.html', }, }), euiIconType: 'logoElasticsearch', artifacts: { application: { label: i18n.translate('kbn.server.tutorials.elasticsearchMetrics.artifacts.application.label', { defaultMessage: 'Discover', }), path: '/app/kibana#/discover' }, dashboards: [], exportedFields: { documentationUrl: '{config.docs.beats.metricbeat}/exported-fields-elasticsearch.html' } }, completionTimeMinutes: 10, onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; }
module.exports = require('@spryker/frontend-config.prettier/.prettierrc.json');
// http://eslint.org/docs/user-guide/configuring module.exports = { "root": true, extends: [ // 'eslint:recommended', 'plugin:vue/recommended' // or 'plugin:vue/base' ], rules: { // override/add rules' settings here // 'vue/valid-v-if': 'error' } } // // module.exports = { // root: true, // parser: 'babel-eslint', // parserOptions: { // sourceType: 'module' // }, // env: { // browser: true, // }, // // https://github.com/standard/standard/blob/master/docs/RULES-en.md // extends: 'standard', // // required to lint *.vue files // plugins: [ // 'html' // ], // // add your custom rules here // 'rules': { // // allow paren-less arrow functions // 'arrow-parens': 0, // // allow async-await // 'generator-star-spacing': 0, // // allow debugger during development // 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 // } // }
import React from "react" import { Link, graphql } from 'gatsby' export default function Home(props) { const { data } = props return <div> Hello world! <Link to="/person/1">toPerson</Link> <Link to="/person/2">toPerson</Link> <p>{data.site.siteMetadata.title}</p> <p>{data.site.siteMetadata.author}</p> </div> } // 页面组件 查询,会存于组件的props的data属性 export const query = graphql` query MyQuery { site { id siteMetadata { author title } } } `
import { NotImplementedError } from '../extensions/index.js'; /** * Extract season from given date and expose the enemy scout! * * @param {Date | FakeDate} date real or fake date * @returns {String} time of the year * * @example * * getSeason(new Date(2020, 02, 31)) => 'spring' * */ export default function getSeason(date) { //throw new NotImplementedError('Not implemented'); function isValidDate(date) { if (Object.keys(date).length > 0 || !(date instanceof Date)) { return false } else { return true } } if (date == undefined) { return 'Unable to determine the time of year!' } else if (isValidDate(date) === false) { throw new Error('Invalid date!') } let mounth = date.getMonth() + 1 if (mounth === 12 || mounth === 1 || mounth === 2) { return 'winter' } else if (mounth === 3 || mounth === 4 || mounth === 5) { return 'spring' } else if (mounth === 6 || mounth === 7 || mounth === 8) { return 'summer' } else if (mounth === 9 || mounth === 10 || mounth === 11) { return 'autumn' } }
goog.provide('goog.i18n.currency'); goog.i18n.currency.PRECISION_MASK_ = 0x07; goog.i18n.currency.POSITION_FLAG_ = 0x08; goog.i18n.currency.SPACE_FLAG_ = 0x20; goog.i18n.currency.addTier2Support = function() { for(var key in goog.i18n.currency.CurrencyInfoTier2) { goog.i18n.currency.CurrencyInfo[key]= goog.i18n.currency.CurrencyInfoTier2[key]; } }; goog.i18n.currency.getGlobalCurrencyPattern = function(currencyCode) { var info = goog.i18n.currency.CurrencyInfo[currencyCode]; var patternNum = info[0]; if(currencyCode == info[1]) { if((patternNum & goog.i18n.currency.POSITION_FLAG_) == 0) { patternNum |= goog.i18n.currency.SPACE_FLAG_; } return goog.i18n.currency.getCurrencyPattern_(patternNum, info[1]); } return currencyCode + ' ' + goog.i18n.currency.getCurrencyPattern_(patternNum, info[1]); }; goog.i18n.currency.getGlobalCurrencySign = function(currencyCode) { var info = goog.i18n.currency.CurrencyInfo[currencyCode]; if(currencyCode == info[1]) { return currencyCode; } return currencyCode + ' ' + info[1]; }; goog.i18n.currency.getLocalCurrencyPattern = function(currencyCode) { var info = goog.i18n.currency.CurrencyInfo[currencyCode]; return goog.i18n.currency.getCurrencyPattern_(info[0], info[1]); }; goog.i18n.currency.getLocalCurrencySign = function(currencyCode) { return goog.i18n.currency.CurrencyInfo[currencyCode][1]; }; goog.i18n.currency.getPortableCurrencyPattern = function(currencyCode) { var info = goog.i18n.currency.CurrencyInfo[currencyCode]; return goog.i18n.currency.getCurrencyPattern_(info[0], info[2]); }; goog.i18n.currency.getPortableCurrencySign = function(currencyCode) { return goog.i18n.currency.CurrencyInfo[currencyCode][2]; }; goog.i18n.currency.isPrefixSignPosition = function(currencyCode) { return(goog.i18n.currency.CurrencyInfo[currencyCode][0]& goog.i18n.currency.POSITION_FLAG_) == 0; }; goog.i18n.currency.getCurrencyPattern_ = function(patternNum, sign) { var strParts =['#,##0']; var precision = patternNum & goog.i18n.currency.PRECISION_MASK_; if(precision > 0) { strParts.push('.'); for(var i = 0; i < precision; i ++) { strParts.push('0'); } } if((patternNum & goog.i18n.currency.POSITION_FLAG_) == 0) { strParts.unshift((patternNum & goog.i18n.currency.SPACE_FLAG_) ? "' ": "'"); strParts.unshift(sign); strParts.unshift("'"); } else { strParts.push((patternNum & goog.i18n.currency.SPACE_FLAG_) ? " '": "'", sign, "'"); } return strParts.join(''); }; goog.i18n.currency.CurrencyInfo = { 'AED':[2, '\u062F\u002e\u0625', 'DH'], 'ARS':[2, '$', 'AR$'], 'AUD':[2, '$', 'AU$'], 'BDT':[2, '\u09F3', 'Tk'], 'BRL':[2, 'R$', 'R$'], 'CAD':[2, '$', 'C$'], 'CHF':[2, 'Fr.', 'CHF'], 'CLP':[0, '$', 'CL$'], 'CNY':[2, '¥', 'RMB¥'], 'COP':[2, '$', 'COL$'], 'CRC':[2, '\u20a1', 'CR₡'], 'CUP':[2, '$', '$MN'], 'CZK':[10, 'Kč', 'Kč'], 'DKK':[26, 'kr', 'kr'], 'DOP':[2, '$', 'RD$'], 'EGP':[2, '£', 'LE'], 'EUR':[26, '€', '€'], 'GBP':[2, '£', 'GB£'], 'HKD':[2, '$', 'HK$'], 'ILS':[10, '\u20AA', 'IL₪'], 'INR':[2, 'Rs', 'Rs'], 'ISK':[10, 'kr', 'kr'], 'JMD':[2, '$', 'JA$'], 'JPY':[0, '¥', 'JP¥'], 'KRW':[0, '\u20A9', 'KR₩'], 'LKR':[2, 'Rs', 'SLRs'], 'MNT':[2, '\u20AE', 'MN₮'], 'MXN':[2, '$', 'Mex$'], 'MYR':[2, 'RM', 'RM'], 'NOK':[26, 'kr', 'NOkr'], 'PAB':[2, 'B/.', 'B/.'], 'PEN':[2, 'S/.', 'S/.'], 'PHP':[2, 'P', 'PHP'], 'PKR':[2, 'Rs.', 'PKRs.'], 'RUB':[10, 'руб', 'руб'], 'SAR':[2, '\u0633\u002E\u0631', 'SR'], 'SEK':[10, 'kr', 'kr'], 'SGD':[2, '$', 'S$'], 'THB':[2, '\u0e3f', 'THB'], 'TRY':[2, 'YTL', 'YTL'], 'TWD':[2, 'NT$', 'NT$'], 'USD':[2, '$', 'US$'], 'UYU':[2, '$', 'UY$'], 'VND':[10, '\u20AB', 'VN₫'], 'YER':[2, 'YER', 'YER'], 'ZAR':[2, 'R', 'ZAR'] }; goog.i18n.currency.CurrencyInfoTier2 = { 'AFN':[18, '\u060b', 'AFN'], 'ALL':[2, 'Lek', 'Lek'], 'AMD':[10, '\u0564\u0580\u002e', 'dram'], 'ANG':[2, '\u0083', 'NAƒ'], 'AOA':[2, 'Kz', 'Kz'], 'AWG':[2, 'ƒ', 'Afl.'], 'AZN':[2, 'm', 'man'], 'BAM':[18, 'КМ', 'KM'], 'BBD':[2, '$', 'Bds$'], 'BGN':[10, '\u043b\u0432', 'лв'], 'BHD':[3, '\u0628\u002e\u062f\u002e', 'BD'], 'BIF':[0, 'FBu', 'FBu'], 'BMD':[2, '$', 'BD$'], 'BND':[2, '$', 'B$'], 'BOB':[2, 'B$', 'B$'], 'BSD':[2, '$', 'B$'], 'BTN':[2, 'Nu.', 'Nu.'], 'BWP':[2, 'P', 'pula'], 'BYR':[0, 'Br', 'Br'], 'BZD':[2, '$', 'BZ$'], 'CDF':[2, 'F', 'CDF'], 'CVE':[2, '$', 'Esc'], 'DJF':[0, 'Fdj', 'Fdj'], 'DZD':[2, '\u062f\u062C', 'DA'], 'EEK':[10, 'EEK', 'EEK'], 'ERN':[2, 'Nfk', 'Nfk'], 'ETB':[2, 'Br', 'Br'], 'FJD':[2, '$', 'FJ$'], 'FKP':[2, '£', 'FK£'], 'GEL':[2, 'GEL', 'GEL'], 'GHS':[2, '\u20B5', 'GHS¢'], 'GIP':[2, '£', 'GI£'], 'GMD':[2, 'D', 'GMD'], 'GNF':[0, 'FG', 'FG'], 'GTQ':[2, 'Q', 'GTQ'], 'GYD':[2, '$', 'GY$'], 'HNL':[2, 'L', 'HNL'], 'HRK':[2, 'kn', 'kn'], 'HTG':[2, 'G', 'HTG'], 'HUF':[10, 'Ft', 'Ft'], 'IDR':[2, 'Rp', 'Rp'], 'IQD':[3, '\u0639\u062F', 'IQD'], 'IRR':[2, '\ufdfc', 'IRR'], 'JOD':[3, 'JOD', 'JOD'], 'KES':[2, 'KSh', 'KSh'], 'KGS':[2, 'som', 'som'], 'KHR':[10, '\u17DB', 'KHR'], 'KMF':[0, 'KMF', 'KMF'], 'KPW':[2, '\u20A9', 'KPW'], 'KWD':[3, '\u062F\u002e\u0643', 'KWD'], 'KYD':[2, '$', 'CI$'], 'KZT':[10, 'KZT', 'KZT'], 'LAK':[2, '\u20AD', 'LA₭'], 'LBP':[2, '\u0644\u002e\u0644', 'LBP'], 'LRD':[2, '$', 'L$'], 'LSL':[2, 'L', 'LSL'], 'LTL':[10, 'Lt', 'Lt'], 'LVL':[10, 'Ls', 'Ls'], 'LYD':[3, '\u0644\u002e\u062F', 'LD'], 'MAD':[2, '\u0645\u002E\u062F\u002E', 'MAD'], 'MDL':[2, 'MDL', 'MDL'], 'MGA':[1, 'MGA', 'MGA'], 'MKD':[2, 'MKD', 'MKD'], 'MMK':[2, 'K', 'MMK'], 'MOP':[2, 'MOP$', 'MOP$'], 'MRO':[1, 'UM', 'UM'], 'MUR':[2, 'Rs', 'MURs'], 'MVR':[2, 'Rf', 'MRF'], 'MWK':[2, 'MK', 'MK'], 'MZN':[2, 'MTn', 'MTn'], 'NAD':[2, '$', 'N$'], 'NGN':[2, '\u20A6', 'NG₦'], 'NIO':[2, 'C$', 'C$'], 'NPR':[2, 'Rs', 'NPRs'], 'NZD':[2, '$', 'NZ$'], 'OMR':[3, '\u0639\u002E\u062F\u002E', 'OMR'], 'PGK':[2, 'K', 'PGK'], 'PLN':[10, 'zł', 'zł'], 'PYG':[0, '\u20b2', 'PYG'], 'QAR':[2, '\u0642\u002E\u0631', 'QR'], 'RON':[2, 'L', 'RON'], 'RSD':[2, 'РС\u0414', 'RSD'], 'RWF':[0, 'RF', 'RF'], 'SBD':[2, '$', 'SI$'], 'SCR':[2, 'SR', 'SCR'], 'SDG':[2, 'SDG', 'SDG'], 'SHP':[2, '£', 'SH£'], 'SKK':[10, 'Sk', 'Sk'], 'SLL':[2, 'Le', 'Le'], 'SOS':[2, 'So. Sh.', 'So. Sh.'], 'SRD':[2, '$', 'SR$'], 'STD':[2, 'Db', 'Db'], 'SYP':[18, 'SYP', 'SYP'], 'SZL':[2, 'L', 'SZL'], 'TJS':[2, 'TJS', 'TJS'], 'TMM':[2, 'm', 'TMM'], 'TND':[3, '\u062F\u002e\u062A ', 'DT'], 'TOP':[2, 'T$', 'T$'], 'TTD':[2, '$', 'TT$'], 'TZS':[10, 'TZS', 'TZS'], 'UAH':[10, '\u20B4', 'грн'], 'UGX':[2, 'USh', 'USh'], 'UZS':[2, 'UZS', 'UZS'], 'VEF':[2, 'Bs.F', 'Bs.F'], 'VUV':[0, 'Vt', 'Vt'], 'WST':[2, 'WS$', 'WS$'], 'XAF':[0, 'FCFA', 'FCFA'], 'XCD':[2, '$', 'EC$'], 'XOF':[0, 'CFA', 'CFA'], 'XPF':[0, 'F', 'XPF'], 'ZMK':[2, 'ZK', 'ZK'], 'ZWL':[2, '$', 'ZW$'] };
import { Component } from "react"; import PropTypes from "prop-types"; import schema from "@times-components-native/schema/schema.json"; import { graphql } from "graphql"; import { print } from "graphql/language/printer"; import mm from "./make-mocks"; const makeMocks = mm(schema); const makeQuery = ({ defaults, delay, error, query, variables, repeatable }) => graphql(makeMocks(defaults), print(query), null, null, variables).then( (mock) => ({ defaults, delay, error, mock, query, variables, repeatable, }), ); const toResponse = ({ delay, error, mock, query, variables, repeatable }) => { const response = { delay, error, request: { query, variables, }, result: mock, }; if (repeatable) { response.newData = () => response.result; } return response; }; export const schemaToMocks = (params) => Promise.all(params.map(makeQuery)).then(([...mocks]) => mocks.map(toResponse), ); class MockFixture extends Component { constructor(props) { super(props); this.state = { mocks: [], }; } componentDidMount() { const { params } = this.props; schemaToMocks(params).then((mocks) => this.setState({ mocks })); } render() { const { render } = this.props; const { mocks } = this.state; return mocks.length === 0 ? null : render(mocks); } } MockFixture.propTypes = { params: PropTypes.arrayOf( PropTypes.shape({ defaults: PropTypes.shape({ types: PropTypes.any, values: PropTypes.any, }), delay: null, query: PropTypes.object.isRequired, variables: PropTypes.object, }), ).isRequired, render: PropTypes.func.isRequired, }; export default MockFixture;
'use strict'; const AuthProvider = require('./auth_provider').AuthProvider; const retrieveKerberos = require('../utils').retrieveKerberos; let kerberos; /** * Creates a new GSSAPI authentication mechanism * @class * @extends AuthProvider */ class GSSAPI extends AuthProvider { /** * Implementation of authentication for a single connection * @override */ _authenticateSingleConnection(sendAuthCommand, connection, credentials, callback) { const source = credentials.source; const username = credentials.username; const password = credentials.password; const mechanismProperties = credentials.mechanismProperties; const gssapiServiceName = mechanismProperties['gssapiservicename'] || mechanismProperties['gssapiServiceName'] || 'mongodb'; GSSAPIInitialize( this, kerberos.processes.MongoAuthProcess, source, username, password, source, gssapiServiceName, sendAuthCommand, connection, mechanismProperties, callback ); } /** * Authenticate * @override * @method */ auth(sendAuthCommand, connections, credentials, callback) { if (kerberos == null) { try { kerberos = retrieveKerberos(); } catch (e) { return callback(e, null); } } super.auth(sendAuthCommand, connections, credentials, callback); } } // // Initialize step var GSSAPIInitialize = function( self, MongoAuthProcess, db, username, password, authdb, gssapiServiceName, sendAuthCommand, connection, options, callback ) { // Create authenticator var mongo_auth_process = new MongoAuthProcess( connection.host, connection.port, gssapiServiceName, options ); // Perform initialization mongo_auth_process.init(username, password, function(err) { if (err) return callback(err, false); // Perform the first step mongo_auth_process.transition('', function(err, payload) { if (err) return callback(err, false); // Call the next db step MongoDBGSSAPIFirstStep( self, mongo_auth_process, payload, db, username, password, authdb, sendAuthCommand, connection, callback ); }); }); }; // // Perform first step against mongodb var MongoDBGSSAPIFirstStep = function( self, mongo_auth_process, payload, db, username, password, authdb, sendAuthCommand, connection, callback ) { // Build the sasl start command var command = { saslStart: 1, mechanism: 'GSSAPI', payload: payload, autoAuthorize: 1 }; // Write the commmand on the connection sendAuthCommand(connection, '$external.$cmd', command, (err, doc) => { if (err) return callback(err, false); // Execute mongodb transition mongo_auth_process.transition(doc.payload, function(err, payload) { if (err) return callback(err, false); // MongoDB API Second Step MongoDBGSSAPISecondStep( self, mongo_auth_process, payload, doc, db, username, password, authdb, sendAuthCommand, connection, callback ); }); }); }; // // Perform first step against mongodb var MongoDBGSSAPISecondStep = function( self, mongo_auth_process, payload, doc, db, username, password, authdb, sendAuthCommand, connection, callback ) { // Build Authentication command to send to MongoDB var command = { saslContinue: 1, conversationId: doc.conversationId, payload: payload }; // Execute the command // Write the commmand on the connection sendAuthCommand(connection, '$external.$cmd', command, (err, doc) => { if (err) return callback(err, false); // Call next transition for kerberos mongo_auth_process.transition(doc.payload, function(err, payload) { if (err) return callback(err, false); // Call the last and third step MongoDBGSSAPIThirdStep( self, mongo_auth_process, payload, doc, db, username, password, authdb, sendAuthCommand, connection, callback ); }); }); }; var MongoDBGSSAPIThirdStep = function( self, mongo_auth_process, payload, doc, db, username, password, authdb, sendAuthCommand, connection, callback ) { // Build final command var command = { saslContinue: 1, conversationId: doc.conversationId, payload: payload }; // Execute the command sendAuthCommand(connection, '$external.$cmd', command, (err, r) => { if (err) return callback(err, false); mongo_auth_process.transition(null, function(err) { if (err) return callback(err, null); callback(null, r); }); }); }; /** * This is a result from a authentication strategy * * @callback authResultCallback * @param {error} error An error object. Set to null if no error present * @param {boolean} result The result of the authentication process */ module.exports = GSSAPI;
import * as React from 'react'; import createSvgIcon from './utils/createSvgIcon'; import { jsx as _jsx } from "react/jsx-runtime"; export default createSvgIcon( /*#__PURE__*/_jsx("path", { d: "M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11zM8 15.01l1.41 1.41L11 14.84V19h2v-4.16l1.59 1.59L16 15.01 12.01 11 8 15.01z" }), 'UploadFileOutlined');
import PropTypes from 'prop-types'; // @mui import { Card, CardHeader, Typography, Stack, LinearProgress } from '@mui/material'; // utils import { fCurrency } from '../../utils/formatNumber'; // _mock_ import { _appCost } from '../../_mock'; // ---------------------------------------------------------------------- export default function AppCost() { return ( <Card> <CardHeader title="Custos atuais" /> <Stack spacing={4} sx={{ p: 3 }}> {_appCost.map((progress) => ( <ProgressItem key={progress.label} progress={progress} /> ))} </Stack> </Card> ); } // ---------------------------------------------------------------------- ProgressItem.propTypes = { progress: PropTypes.shape({ amount: PropTypes.number, label: PropTypes.string, value: PropTypes.number, }), }; function ProgressItem({ progress }) { return ( <Stack spacing={1}> <Stack direction="row" alignItems="center"> <Typography variant="subtitle2" sx={{ flexGrow: 1 }}> {progress.label} </Typography> <Typography variant="subtitle2">{fCurrency(progress.amount)}</Typography> <Typography variant="body2" sx={{ color: 'text.secondary' }}> &nbsp;({`${progress.value}%`}) </Typography> </Stack> <LinearProgress variant="determinate" value={progress.value} color={ (progress.label === 'Impostos' && 'warning') || 'primary' } /> </Stack> ); }
/*========================================================================================= File Name: store.js Description: Vuex store ---------------------------------------------------------------------------------------- Item Name: Tripcarte.Asia Dashboard Management Portal Author: Tripcarte.Asia Staging URL: http://tripcarte.gispatial.tech/api ==========================================================================================*/ import Vue from 'vue' import Vuex from 'vuex' import state from "./state" import getters from "./getters" import mutations from "./mutations" import actions from "./actions" Vue.use(Vuex) // import moduleTodo from './todo/moduleTodo.js' // import moduleCalendar from './calendar/moduleCalendar.js' // import moduleChat from './chat/moduleChat.js' // import moduleEmail from './email/moduleEmail.js' import moduleAuth from './auth/moduleAuth.js' import moduleECommerce from './eCommerce/moduleECommerce.js' //import moduleCommission from './commission/moduleCommission.js' export default new Vuex.Store({ getters, mutations, state, actions, modules: { // todo: moduleTodo, // calendar: moduleCalendar, // chat: moduleChat, // email: moduleEmail, auth: moduleAuth, eCommerce: moduleECommerce, //commission: moduleCommission }, strict: process.env.NODE_ENV !== 'production' })
import { hypot } from 'dummy/helpers/hypot'; import { module, test } from 'qunit'; module('Unit | Helper | hypot', function () { test('hypot works', function (assert) { const result = hypot([3, 4, 5]); assert.strictEqual(result, 7.0710678118654755); }); });
(function(a){a.jqplot.CanvasAxisLabelRenderer=function(b){this.angle=0;this.axis;this.show=true;this.showLabel=true;this.label="";this.fontFamily='"Trebuchet MS", Arial, Helvetica, sans-serif';this.fontSize="11pt";this.fontWeight="normal";this.fontStretch=1;this.textColor="#666666";this.enableFontSupport=true;this.pt2px=null;this._elem;this._ctx;this._plotWidth;this._plotHeight;this._plotDimensions={height:null,width:null};a.extend(true,this,b);if(b.angle==null&&this.axis!="xaxis"&&this.axis!="x2axis"){this.angle=-90}var c={fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily};if(this.pt2px){c.pt2px=this.pt2px}if(this.enableFontSupport){if(a.jqplot.support_canvas_text()){this._textRenderer=new a.jqplot.CanvasFontRenderer(c)}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}}else{this._textRenderer=new a.jqplot.CanvasTextRenderer(c)}};a.jqplot.CanvasAxisLabelRenderer.prototype.init=function(b){a.extend(true,this,b);this._textRenderer.init({fontSize:this.fontSize,fontWeight:this.fontWeight,fontStretch:this.fontStretch,fillStyle:this.textColor,angle:this.getAngleRad(),fontFamily:this.fontFamily})};a.jqplot.CanvasAxisLabelRenderer.prototype.getWidth=function(d){if(this._elem){return this._elem.outerWidth(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.sin(f.angle)*e)+Math.abs(Math.cos(f.angle)*c);return b}};a.jqplot.CanvasAxisLabelRenderer.prototype.getHeight=function(d){if(this._elem){return this._elem.outerHeight(true)}else{var f=this._textRenderer;var c=f.getWidth(d);var e=f.getHeight(d);var b=Math.abs(Math.cos(f.angle)*e)+Math.abs(Math.sin(f.angle)*c);return b}};a.jqplot.CanvasAxisLabelRenderer.prototype.getAngleRad=function(){var b=this.angle*Math.PI/180;return b};a.jqplot.CanvasAxisLabelRenderer.prototype.draw=function(c,f){if(this._elem){if(a.jqplot.use_excanvas&&window.G_vmlCanvasManager.uninitElement!==undefined){window.G_vmlCanvasManager.uninitElement(this._elem.get(0))}this._elem.emptyForce();this._elem=null}var e=f.canvasManager.getCanvas();this._textRenderer.setText(this.label,c);var b=this.getWidth(c);var d=this.getHeight(c);e.width=b;e.height=d;e.style.width=b;e.style.height=d;e=f.canvasManager.initCanvas(e);this._elem=a(e);this._elem.css({position:"absolute"});this._elem.addClass("jqplot-"+this.axis+"-label");e=null;return this._elem};a.jqplot.CanvasAxisLabelRenderer.prototype.pack=function(){this._textRenderer.draw(this._elem.get(0).getContext("2d"),this.label)}})(jQuery);
import os import warnings import re from timeit import default_timer as timer from numpy import unique from skmultiflow.evaluation.base_evaluator import StreamEvaluator from skmultiflow.utils import constants class EvaluatePrequential(StreamEvaluator): """ The prequential evaluation method or interleaved test-then-train method. An alternative to the traditional holdout evaluation, inherited from batch setting problems. The prequential evaluation is designed specifically for stream settings, in the sense that each sample serves two purposes, and that samples are analysed sequentially, in order of arrival, and become immediately inaccessible. This method consists of using each sample to test the model, which means to make a predictions, and then the same sample is used to train the model (partial fit). This way the model is always tested on samples that it hasn't seen yet. Parameters ---------- n_wait: int (Default: 200) The number of samples to process between each test. Also defines when to update the plot if `show_plot=True`. Note that setting `n_wait` too small can significantly slow the evaluation process. max_samples: int (Default: 100000) The maximum number of samples to process during the evaluation. batch_size: int (Default: 1) The number of samples to pass at a time to the model(s). pretrain_size: int (Default: 200) The number of samples to use to train the model before starting the evaluation. Used to enforce a 'warm' start. max_time: float (Default: float("inf")) The maximum duration of the simulation (in seconds). metrics: list, optional (Default: ['accuracy', 'kappa']) | The list of metrics to track during the evaluation. Also defines the metrics that will be displayed in plots and/or logged into the output file. Valid options are | **Classification** | 'accuracy' | 'kappa' | 'kappa_t' | 'kappa_m' | 'true_vs_predicted' | 'precision' | 'recall' | 'f1' | 'gmean' | **Multi-target Classification** | 'hamming_score' | 'hamming_loss' | 'exact_match' | 'j_index' | **Regression** | 'mean_square_error' | 'mean_absolute_error' | 'true_vs_predicted' | **Multi-target Regression** | 'average_mean_squared_error' | 'average_mean_absolute_error' | 'average_root_mean_square_error' | **General purpose** (no plot generated) | 'running_time' | 'model_size' output_file: string, optional (Default: None) File name to save the summary of the evaluation. show_plot: bool (Default: False) If True, a plot will show the progress of the evaluation. Warning: Plotting can slow down the evaluation process. restart_stream: bool, optional (default: True) If True, the stream is restarted once the evaluation is complete. data_points_for_classification: bool(Default: False) If True, the visualization used is a cloud of data points (only works for classification) and default performance metrics are ignored. If specific metrics are required, then they *must* be explicitly set using the ``metrics`` attribute. Notes ----- 1. This evaluator can process a single learner to track its performance; or multiple learners at a time, to compare different models on the same stream. 2. The metric 'true_vs_predicted' is intended to be informative only. It corresponds to evaluations at a specific moment which might not represent the actual learner performance across all instances. 3. The metrics `running_time` and `model_size ` are not plotted when the `show_plot` option is set. Only their current value is displayed at the bottom of the figure. However, their values over the evaluation are written into the resulting csv file if the `output_file` option is set. Examples -------- >>> # The first example demonstrates how to evaluate one model >>> from skmultiflow.data import SEAGenerator >>> from skmultiflow.trees import HoeffdingTreeClassifier >>> from skmultiflow.evaluation import EvaluatePrequential >>> >>> # Set the stream >>> stream = SEAGenerator(random_state=1) >>> >>> # Set the model >>> ht = HoeffdingTreeClassifier() >>> >>> # Set the evaluator >>> >>> evaluator = EvaluatePrequential(max_samples=10000, >>> max_time=1000, >>> show_plot=True, >>> metrics=['accuracy', 'kappa']) >>> >>> # Run evaluation >>> evaluator.evaluate(stream=stream, model=ht, model_names=['HT']) >>> # The second example demonstrates how to compare two models >>> from skmultiflow.data import SEAGenerator >>> from skmultiflow.trees import HoeffdingTreeClassifier >>> from skmultiflow.bayes import NaiveBayes >>> from skmultiflow.evaluation import EvaluateHoldout >>> >>> # Set the stream >>> stream = SEAGenerator(random_state=1) >>> >>> # Set the models >>> ht = HoeffdingTreeClassifier() >>> nb = NaiveBayes() >>> >>> evaluator = EvaluatePrequential(max_samples=10000, >>> max_time=1000, >>> show_plot=True, >>> metrics=['accuracy', 'kappa']) >>> >>> # Run evaluation >>> evaluator.evaluate(stream=stream, model=[ht, nb], model_names=['HT', 'NB']) >>> # The third example demonstrates how to evaluate one model >>> # and visualize the predictions using data points. >>> # Note: You can not in this case compare multiple models >>> from skmultiflow.data import SEAGenerator >>> from skmultiflow.trees import HoeffdingTreeClassifier >>> from skmultiflow.evaluation import EvaluatePrequential >>> # Set the stream >>> stream = SEAGenerator(random_state=1) >>> # Set the model >>> ht = HoeffdingTreeClassifier() >>> # Set the evaluator >>> evaluator = EvaluatePrequential(max_samples=200, >>> n_wait=1, >>> pretrain_size=1, >>> max_time=1000, >>> show_plot=True, >>> metrics=['accuracy'], >>> data_points_for_classification=True) >>> >>> # Run evaluation >>> evaluator.evaluate(stream=stream, model=ht, model_names=['HT']) """ def __init__(self, n_wait=200, max_samples=100000, batch_size=1, pretrain_size=200, max_time=float("inf"), metrics=None, output_file=None, show_plot=False, restart_stream=True, data_points_for_classification=False): super().__init__() self._method = 'prequential' self.n_wait = n_wait self.max_samples = max_samples self.pretrain_size = pretrain_size self.batch_size = batch_size self.max_time = max_time self.output_file = output_file self.show_plot = show_plot self.data_points_for_classification = data_points_for_classification if not self.data_points_for_classification: if metrics is None: self.metrics = [constants.ACCURACY, constants.KAPPA] else: if isinstance(metrics, list): self.metrics = metrics else: raise ValueError("Attribute 'metrics' must be 'None' or 'list', passed {}".format(type(metrics))) else: if metrics is None: self.metrics = [constants.DATA_POINTS] else: if isinstance(metrics, list): self.metrics = metrics self.metrics.append(constants.DATA_POINTS) else: raise ValueError("Attribute 'metrics' must be 'None' or 'list', passed {}".format(type(metrics))) self.restart_stream = restart_stream self.n_sliding = n_wait warnings.filterwarnings("ignore", ".*invalid value encountered in true_divide.*") warnings.filterwarnings("ignore", ".*Passing 1d.*") def evaluate(self, stream, model, model_names=None): """ Evaluates a model or set of models on samples from a stream. Parameters ---------- stream: Stream The stream from which to draw the samples. model: skmultiflow.core.BaseStreamModel or sklearn.base.BaseEstimator or list The model or list of models to evaluate. model_names: list, optional (Default=None) A list with the names of the models. Returns ------- StreamModel or list The trained model(s). """ self._init_evaluation(model=model, stream=stream, model_names=model_names) if self._check_configuration(): self._reset_globals() # Initialize metrics and outputs (plots, log files, ...) self._init_metrics() self._init_plot() self._init_file() self.model = self._train_and_test() if self.show_plot: self.visualizer.hold() return self.model def _train_and_test(self): """ Method to control the prequential evaluation. Returns ------- BaseClassifier extension or list of BaseClassifier extensions The trained classifiers. Notes ----- The classifier parameter should be an extension from the BaseClassifier. In the future, when BaseRegressor is created, it could be an extension from that class as well. """ self._start_time = timer() self._end_time = timer() print('Prequential Evaluation') print('Evaluating {} target(s).'.format(self.stream.n_targets)) actual_max_samples = self.stream.n_remaining_samples() if actual_max_samples == -1 or actual_max_samples > self.max_samples: actual_max_samples = self.max_samples first_run = True if self.pretrain_size > 0: print('Pre-training on {} sample(s).'.format(self.pretrain_size)) X, y = self.stream.next_sample(self.pretrain_size) for i in range(self.n_models): if self._task_type == constants.CLASSIFICATION: # Training time computation self.running_time_measurements[i].compute_training_time_begin() self.model[i].partial_fit(X=X, y=y, classes=self.stream.target_values) self.running_time_measurements[i].compute_training_time_end() elif self._task_type == constants.MULTI_TARGET_CLASSIFICATION: self.running_time_measurements[i].compute_training_time_begin() self.model[i].partial_fit(X=X, y=y, classes=unique(self.stream.target_values)) self.running_time_measurements[i].compute_training_time_end() else: self.running_time_measurements[i].compute_training_time_begin() self.model[i].partial_fit(X=X, y=y) self.running_time_measurements[i].compute_training_time_end() self.running_time_measurements[i].update_time_measurements(self.pretrain_size) self.global_sample_count += self.pretrain_size first_run = False update_count = 0 print('Evaluating...') while ((self.global_sample_count < actual_max_samples) & (self._end_time - self._start_time < self.max_time) & (self.stream.has_more_samples())): try: X, y = self.stream.next_sample(self.batch_size) if X is not None and y is not None: # Test prediction = [[] for _ in range(self.n_models)] for i in range(self.n_models): try: # Testing time self.running_time_measurements[i].compute_testing_time_begin() if self.model[i].__class__.__name__ == 'AutonomousNN': prediction[i].extend(self.model[i].predict(X, y)) else: prediction[i].extend(self.model[i].predict(X)) self.running_time_measurements[i].compute_testing_time_end() except TypeError: raise TypeError("Unexpected prediction value from {}" .format(type(self.model[i]).__name__)) self.global_sample_count += self.batch_size for j in range(self.n_models): for i in range(len(prediction[0])): self.mean_eval_measurements[j].add_result(y[i], prediction[j][i]) self.current_eval_measurements[j].add_result(y[i], prediction[j][i]) self._check_progress(actual_max_samples) # Train if first_run: for i in range(self.n_models): if self._task_type != constants.REGRESSION and \ self._task_type != constants.MULTI_TARGET_REGRESSION: # Accounts for the moment of training beginning self.running_time_measurements[i].compute_training_time_begin() self.model[i].partial_fit(X, y, self.stream.target_values) # Accounts the ending of training self.running_time_measurements[i].compute_training_time_end() else: self.running_time_measurements[i].compute_training_time_begin() self.model[i].partial_fit(X, y) self.running_time_measurements[i].compute_training_time_end() # Update total running time self.running_time_measurements[i].update_time_measurements(self.batch_size) first_run = False else: for i in range(self.n_models): self.running_time_measurements[i].compute_training_time_begin() self.model[i].partial_fit(X, y) self.running_time_measurements[i].compute_training_time_end() self.running_time_measurements[i].update_time_measurements(self.batch_size) if ((self.global_sample_count % self.n_wait) == 0 or (self.global_sample_count >= actual_max_samples) or (self.global_sample_count / self.n_wait > update_count + 1)): if prediction is not None: self._update_metrics() update_count += 1 self._end_time = timer() except BaseException as exc: print(exc) if exc is KeyboardInterrupt: self._update_metrics() break # call module stream_ended if available for i in range(self.n_models): if self.model[i].__class__.__name__ == 'DeepNNPytorch': # if self.model[i].stream_ended: self.model[i].stream_ended() # Flush file buffer, in case it contains data self._flush_file_buffer() if len(set(self.metrics).difference({constants.DATA_POINTS})) > 0: self.evaluation_summary() else: print('Done') if self.restart_stream: self.stream.restart() return self.model def partial_fit(self, X, y, classes=None, sample_weight=None): """ Partially fit all the models on the given data. Parameters ---------- X: Numpy.ndarray of shape (n_samples, n_features) The data upon which the algorithm will create its model. y: Array-like An array-like containing the classification labels / target values for all samples in X. classes: list Stores all the classes that may be encountered during the classification task. Not used for regressors. sample_weight: Array-like Samples weight. If not provided, uniform weights are assumed. Returns ------- EvaluatePrequential self """ if self.model is not None: for i in range(self.n_models): if self._task_type == constants.CLASSIFICATION or \ self._task_type == constants.MULTI_TARGET_CLASSIFICATION: self.model[i].partial_fit(X=X, y=y, classes=classes, sample_weight=sample_weight) else: self.model[i].partial_fit(X=X, y=y, sample_weight=sample_weight) return self else: return self def predict(self, X): """ Predicts with the estimator(s) being evaluated. Parameters ---------- X: Numpy.ndarray of shape (n_samples, n_features) All the samples we want to predict the label for. Returns ------- list of numpy.ndarray Model(s) predictions """ predictions = None if self.model is not None: predictions = [] for i in range(self.n_models): predictions.append(self.model[i].predict(X)) return predictions def get_info(self): info = self.__repr__() if self.output_file is not None: _, filename = os.path.split(self.output_file) info = re.sub(r"output_file=(.\S+),", "output_file='{}',".format(filename), info) return info
import * as React from 'react'; import * as Scrivito from 'scrivito'; import placeholderCss from '../utils/placeholderCss'; const InPlaceEditingPlaceholder = ({ children, center, block }) => { if (!Scrivito.isInPlaceEditingActive()) { return null; } const innerSpan = <span style={ placeholderCss }>{ children }</span>; if (center) { return <div className="text-center">{ innerSpan }</div>; } if (block) { return <div>{ innerSpan }</div>; } return innerSpan; }; export default InPlaceEditingPlaceholder;
# Description # 中文 # English # Give a string, you can choose to split the string after one character or two adjacent characters, and make the string to be composed of only one character or two characters. Output all possible results. # Have you met this question in a real interview? # Example # Example1 # Input: "123" # Output: [["1","2","3"],["12","3"],["1","23"]] # Example2 # Input: "12345" # Output: [["1","23","45"],["12","3","45"],["12","34","5"],["1","2","3","45"],["1","2","34","5"],["1","23","4","5"],["12","3","4","5"],["1","2","3","4","5"]] # Related Problems # Own Solution class Solution: """ @param: : a string to be split @return: all possible split string array """ def splitString(self, s): # write your code here # s = sorted(s) result = [] combine = [] if not s: return [[]] is_full = False self.dfs(0, s, combine, result, is_full) return result def dfs(self, index, s, combine, result, is_full): if is_full: result.append(list(combine)) if index < len(s): for j in range(2): if j == 0: combine.append(s[index]) if index == len(s) - 1 and combine[0][0] == s[0]: is_full = True else: is_full = False self.dfs(index + 1, s, combine, result, is_full) combine.pop() elif index + 1 < len(s): combine.append(s[index]+s[index + 1]) if index + 1 == len(s) - 1 and combine[0][0] == s[0]: is_full = True else: is_full = False self.dfs(index + 2, s, combine, result, is_full) combine.pop()
import sys while True: N1=format(int(input()),'02') # start : 26 print(N1) N2=N1//10 + N1%10 # new : 2+6 = 8 N3=(N1%10)*10+(N1%10) # new1 : 60+8 = 68 new2=new1//10 + new1%10 # new2 : 6+8 = 14 new3=(new1%10)*10+(new2%10) # new3 : 80+4 = 84
var Helper = require("@kaoscript/runtime").Helper; module.exports = function() { let Space = Helper.enum(String, { RGB: "rgb", SRGB: "srgb" }); return { Space: Space }; };
/* Copyright 2021 Expedia, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import React from 'react'; import styles from './Posts.module.css'; import useScript from 'react-script-hook'; function Posts({link}) { useScript({ src: "https://medium-widget.pixelpoint.io/widget.js", onload: () => { MediumWidget.Init({ renderTo: `.${styles.mediumWidgetPosts}`, params: { "resource": `${link}`, "postsPerLine": 1, "limit": 10, "picture": "small", "fields": ["description", "author", "publishAt"], "ratio": "square" }}) } }); return ( <div className={styles.mediumWidget}> <div className={styles.mediumWidgetPosts}> <h3>Loading posts..</h3> </div> </div> ); } export default Posts;
/** * @fileoverview Forbid target='_blank' attribute * @author Kevin Miller */ 'use strict'; const docsUrl = require('../util/docsUrl'); const linkComponentsUtil = require('../util/linkComponents'); // ------------------------------------------------------------------------------ // Rule Definition // ------------------------------------------------------------------------------ function isTargetBlank(attr) { return attr.name && attr.name.name === 'target' && attr.value && attr.value.type === 'Literal' && attr.value.value.toLowerCase() === '_blank'; } function hasExternalLink(element, linkAttribute) { return element.attributes.some(attr => attr.name && attr.name.name === linkAttribute && attr.value.type === 'Literal' && /^(?:\w+:|\/\/)/.test(attr.value.value)); } function hasDynamicLink(element, linkAttribute) { return element.attributes.some(attr => attr.name && attr.name.name === linkAttribute && attr.value.type === 'JSXExpressionContainer'); } function hasSecureRel(element) { return element.attributes.find((attr) => { if (attr.type === 'JSXAttribute' && attr.name.name === 'rel') { const tags = attr.value && attr.value.type === 'Literal' && attr.value.value.toLowerCase().split(' '); return tags && (tags.indexOf('noopener') >= 0 && tags.indexOf('noreferrer') >= 0); } return false; }); } module.exports = { meta: { docs: { description: 'Forbid target="_blank" attribute without rel="noopener noreferrer"', category: 'Best Practices', recommended: true, url: docsUrl('jsx-no-target-blank') }, schema: [{ type: 'object', properties: { enforceDynamicLinks: { enum: ['always', 'never'] } }, additionalProperties: false }] }, create(context) { const configuration = context.options[0] || {}; const enforceDynamicLinks = configuration.enforceDynamicLinks || 'always'; const components = linkComponentsUtil.getLinkComponents(context); return { JSXAttribute(node) { if (!components.has(node.parent.name.name) || !isTargetBlank(node) || hasSecureRel(node.parent)) { return; } const linkAttribute = components.get(node.parent.name.name); if (hasExternalLink(node.parent, linkAttribute) || (enforceDynamicLinks === 'always' && hasDynamicLink(node.parent, linkAttribute))) { context.report({ node, message: 'Using target="_blank" without rel="noopener noreferrer" ' + 'is a security risk: see https://mathiasbynens.github.io/rel-noopener' }); } } }; } };
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # # Copyright 2013 UnitedStack, Inc. # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # # @author: CingHu, UnitedStack, Inc import pickle import eventlet import netaddr import os import json import jsonpickle from oslo.config import cfg from oslo import messaging from oslo.utils import excutils from neutron.common import constants as l3_constants from neutron.common import rpc as n_rpc from neutron.common import topics from neutron.common import utils as common_utils from neutron.openstack.common import log as logging from neutron.openstack.common.gettextutils import _LI, _LE, _LW from neutron import context as n_context from neutron.plugins.common import constants as s_constants from neutron.services.vm.agent import config as vm_config from neutron.services.vm.common import constants as s_constants from neutron.services.vm.agent import device_status from neutron.services.vm.agent import driver_mgt from neutron.services.vm.agent import svmagt_exception as svmt_exception LOG = logging.getLogger(__name__) N_ROUTER_PREFIX = 'vr-' SERVICE_CLASS_INFO_MAP = { s_constants.VROUTER: 'RouterInfo' } class RouterInfo(object): """Wrapper class around the (neutron) router dictionary. Information about the neutron router is exchanged as a python dictionary between plugin and config agent. RouterInfo is a wrapper around that dict, with attributes for common parameters. These attributes keep the state of the current router configuration, and are used for detecting router state changes when an updated router dict is received. """ def __init__(self, router_id, router): self.device_id = router['device_dict']['id'] self.router_id = router_id self.ex_gw_ports = None self.mgmt_ports = None self.ex_gw_fips = 'Invalid' self._snat_enabled = None self.internal_ports = [] self.floating_ips = [] self._router = None self.router = router self.routes = [] @property def router(self): return self._router @property def id(self): return self.router_id @property def snat_enabled(self): return self._snat_enabled @router.setter def router(self, value): self._router = value if not self._router: return # enable_snat by default if it wasn't specified by plugin self._snat_enabled = self._router.get('enable_snat', True) @property def router_name(self): return N_ROUTER_PREFIX + self.router_id[:11] class ServiceHelper(object): def __init__(self, host, conf, svm_agent, plugin_rpc): self.conf = conf self.host = host self.svm_agent = svm_agent self.plugin_rpc = plugin_rpc self.context = n_context.get_admin_context_without_session() self._dev_status = device_status.DeviceStatus() self._drivermgr = driver_mgt.DeviceDriverManager() self.service_instance = {} self.service_type = {} self.router_dict = {} self.added_services = set() self.updated_services = set() self.removed_services = set() self.sync_devices = set() self.fullsync = True self._service_type_process_register() def _service_type_process_register(self): self.service_type_func = { s_constants.VROUTER: 'process_router', } def dump_service_instance(self, service_instance=None): try: data_path = file(os.path.join( self.conf.servicevm_agent.servicevm_dir, "servicevm-agent.pickle"), 'w') except IOError as e: LOG.error(e) if service_instance: pickle.dump(service_instance, data_path) def _sync_service_instance(self): LOG.info(_('Now load service instance')) empty = (set(), set(), set()) current_service_instance_ids = set(self._fetch_service_ids()) try: data_path = file(os.path.join( self.conf.servicevm_agent.servicevm_dir, "servicevm-agent.pickle"), 'r') self.service_instance = pickle.load(data_path) except IOError as e: if e.errno == 2: os.makedirs(self.conf.servicevm_agent.servicevm_dir) data_path = file(os.path.join( self.conf.servicevm_agent.servicevm_dir, "servicevm-agent.pickle"), 'wr') self.service_instance = pickle.load(data_path) except EOFError as e: LOG.warn('It is no service instance') self.service_instance = {} except Exception as e: self.fullsync = True LOG.error(e) return empty LOG.info(_("Init sync completed, get %s service instance"), len(self.service_instance)) exist_service_instance_ids = set(self.service_instance.keys()) added_services = current_service_instance_ids-exist_service_instance_ids updated_services = current_service_instance_ids&exist_service_instance_ids deleted_services = exist_service_instance_ids-current_service_instance_ids self.fullsync = False return (added_services, updated_services, deleted_services) ### Notifications from Plugin #### def create_device(self, context, device): pass def update_device(self, context, device): pass def delete_device(self, context, device): pass def create_service_instance(self, context, device, service_instance): self.added_services.add(service_instance['id']) def update_service_instance(self, context, device, service_instance): self.updated_services.add(service_instance['id']) def delete_service_instance(self, context, device, service_instance): self.removed_services.add(service_instance['id']) ### service helper public methods ### def process_services(self, device_ids=None, removed_devices=None): try: LOG.debug("service processing started") resources = {} services = {} added_service_instances = [] updated_service_instances = [] removed_services = [] all_services_flag = False if self.fullsync: LOG.info("FullSync flag is on. Starting fullsync") all_services_flag = True self.fullsync = False self.added_services.clear() self.updated_services.clear() self.removed_services.clear() self.sync_devices.clear() (self.added_services, self.updated_services, self.removed_services) = self._sync_service_instance() #else: if True: if self.added_services: service_instance_ids = list(self.added_services) LOG.info("added service instances:%s", service_instance_ids) self.added_services.clear() added_service_instances = self._fetch_services( service_instance_ids=service_instance_ids) if self.updated_services: service_instance_ids = list(self.updated_services) LOG.info("Updated service instances:%s", service_instance_ids) self.updated_services.clear() updated_service_instances = self._fetch_services( service_instance_ids=service_instance_ids) if device_ids: LOG.debug("Adding new devices:%s", device_ids) self.sync_devices = set(device_ids) | self.sync_devices if self.sync_devices: sync_devices_list = list(self.sync_devices) LOG.info("Fetching service instances on:%s", sync_devices_list) updated_service_instances.extend(self._fetch_services( device_ids=sync_devices_list)) self.sync_devices.clear() if removed_devices: ids = self._get_service_instance_ids_from_removed_devices( removed_devices) self.removed_services = self.removed_services | set(ids) if self.removed_services: removed_service_instances_ids = list(self.removed_services) #self.removed_services.clear() LOG.info("Removed services:%s", removed_service_instances_ids) for s in removed_service_instances_ids: if s in self.service_instance: removed_services.append(self.service_instance[s]) self.removed_services.clear() # Sort on hosting device if added_service_instances: resources['added_services'] = added_service_instances if updated_service_instances: resources['updated_services'] = updated_service_instances if removed_services: resources['removed_services'] = removed_services if not resources: LOG.debug('It is not resource to be processed') return hosting_devices = self._sort_resources_per_hosting_device( resources) LOG.info("after sort resource, hosting devices: %s", hosting_devices) pool = eventlet.GreenPool() for device_id, services in hosting_devices.items(): for service_type, resources in services.items(): added_services = resources.get('added_services', []) updated_services = resources.get('updated_services', []) removed_services = resources.get('removed_services', []) process_func = getattr(self, self.service_type_func[service_type]) pool = eventlet.GreenPool() pool.spawn_n(process_func, added_services, removed_services, updated_services, device_id, all_service_instance=all_services_flag) pool.waitall() # save hosting device if added_service_instances: self._service_instance_added_updated(added_service_instances) if updated_service_instances: self._service_instance_added_updated(updated_service_instances) if removed_services: LOG.info('removed services %s', removed_services) self._service_instance_removed(removed_services) self.dump_service_instance(service_instance=self.service_instance) #huxn update, 2015.9.26 #if removed_services: # for hd_id in removed_services['hosting_data']: # self._drivermgr.remove_driver_for_hosting_device(hd_id) LOG.debug("service processing successfully completed") except Exception: LOG.exception(_LE("Failed processing services")) self.fullsync = True # service helper internal methods def _fetch_services(self, service_instance_ids=None, device_ids=None, all_services=False): """Fetch services dict from the servicd plugin. :param service_instance_ids: List of service_instance_ids of services to fetch :param device_ids: List of device_ids whose services to fetch :param all_services If True fetch all the service instances for this agent. :return: List of service_instance dicts of format: [ {service_dict1}, {service_dict2},.....] """ try: if all_services: r = self.plugin_rpc.get_service_instances(self.context) if service_instance_ids: r = self.plugin_rpc.get_service_instances(self.context, service_instance_ids=service_instance_ids) if device_ids: r = self.plugin_rpc.get_service_instances(self.context, device_ids=device_ids) return r except svmt_exception.DriverException as e: LOG.exception(_LE("RPC Error in fetching services from plugin")) #self.fullsync = True def _fetch_service_ids(self, all_service=True, device_ids=None): try: if all_service: r = self.plugin_rpc.fetch_service_ids(self.context) if device_ids: r = self.plugin_rpc.fetch_service_ids(self.context, device_ids=device_ids) return r except svmt_exception.DriverException as e: LOG.exception(_LE("RPC Error in fetching service ids from plugin")) self.fullsync = True def _get_service_instance_ids_from_removed_devices(removed_devices): """Extract service_instance_ids from the removed devices info dict. :param removed_devices: Dict of removed devices and their associated resources. Format: { 'hosting_data': {'hd_id1': {'service_instances': [id1, id2, ...]}, 'hd_id2': {'service_instances': [id3, id4, ...]}, ... }, 'deconfigure': True/False } :return removed_service_instance_ids: List of removed service instance ids """ removed_service_instance_ids = [] for hd_id, resources in removed_devices['hosting_data'].items(): removed_service_instance_ids+=resources.get('service_instances', []) return removed_service_instance_ids def _sort_resources_per_hosting_device(self, resources): """This function will sort the resources on hosting device. The sorting on hosting device is done by looking up the `hosting_device` attribute of the resource, and its `id`. :param resources: a dict with key of resource name :return dict sorted on the hosting device of input resource. Format: hosting_devices = { 'hd_id1' : { 'vrouter':{'added_services':[services] 'removed_services':[services], 'updated_services':[services], .... } 'vfirewall':{'added_services':[services] 'removed_services':[services], 'updated_services':[services], .... } } 'hd_id2' : { 'vrouter':{'added_services':[services] 'removed_services':[services], 'updated_services':[services], .... } } ....... } """ hosting_devices = {} for key in resources.keys(): services = {} for s in resources.get(key) or []: hd_id = s['device_dict']['id'] hosting_devices.setdefault(hd_id, {}) subservice = {} service_type = s.get('service_type').get('servicetype') subservice.setdefault(key,[]).append(s) services[service_type] = subservice hosting_devices[hd_id] = services return hosting_devices def _check_valid_services(self, service): service_type = service.get('service_type').get('servicetype') if service_type not in s_constants.SUPPORT_SERVICE_TYPE: LOG.info(_LI("Service Type %(service_type)s is not support"), {'service_type':service_type}) return False device = service['device_dict'] if not self._dev_status.is_device_reachable(device): LOG.info(_LI("Service: %(id)s is on an unreachable " "hosting device. "), {'id': device['id']}) return False return True def process_router(self, added_services=None, removed_services=None, updated_services=None, device_id=None, all_service_instance=False): try: if all_service_instance: prev_vrouter_ids = set(self.service_type.get( s_constants.VROUTER, [])) else: prev_vrouter_ids = set(self.service_type.get( s_constants.VROUTER, [])) for r in (added_services + updated_services): try: # if not r['admin_state_up']: # continue hd = r['device_dict'] if r['id'] not in self.router_dict: self._router_added(r['id'], r) ri = self.router_dict[r['id']] ri.router = r self._process_router(ri) except KeyError as e: LOG.exception(_LE("Key Error, missing key: %s"), e) self.updated_services.add(r['id']) continue except svmt_exception.DriverException as e: LOG.exception(_LE("Driver Exception on router:%(id)s. " "Error is %(e)s"), {'id': r['id'], 'e': e}) self.updated_services.add(r['id']) continue if removed_services: for router in removed_services: self._router_removed(router['id']) except Exception: LOG.exception(_LE("Exception in processing routers on device:%s"), device_id) self.sync_devices.add(device_id) def _set_value(self, dict, key, value): if key not in dict: dict[key] = value def _service_instance_added_updated(self, service_instances): for s in service_instances: if s['id'] in self.service_instance: del self.service_instance[s['id']] self.service_instance[s['id']] = s def _service_instance_removed(self, service_instances): for s in service_instances: if s['id']in self.service_instance: del self.service_instance[s['id']] def _router_added(self, router_id, router): """Operations when a router is added. Create a new RouterInfo object for this router and add it to the service helpers router_info dictionary. Then `router_added()` is called on the device driver. :param router_id: id of the router :param router: router dict :return: None """ try: ri = RouterInfo(router_id, router) driver = self._drivermgr.get_driver(ri.device_id) driver.router_added(ri) self.service_type.setdefault(s_constants.VROUTER,[]).append(router_id) self.router_dict[router_id] = ri except AttributeError as e: LOG.error(e) raise svmt_exception.DeviceNotConnection(device_id=ri.device_id) except Exception: with excutils.save_and_reraise_exception(): LOG.error("driver config fail ") def _router_removed(self, router_id, deconfigure=True): """Operations when a router is removed. Get the RouterInfo object corresponding to the router in the service helpers's router_info dict. If deconfigure is set to True, remove this router's configuration from the hosting device. :param router_id: id of the router :param deconfigure: if True, the router's configuration is deleted from the hosting device. :return: None """ if router_id in self.router_dict: ri = self.router_dict[router_id] if ri is None: LOG.warning(_LW("Info for router %s was not found. " "Skipping router removal"), router_id) return else: LOG.warning(_LW("Info for router %s was not found. " "Skipping router removal"), router_id) return ri.router[l3_constants.INTERFACE_KEY] = [] ri.router[l3_constants.FLOATINGIP_KEY] = [] ri.router[l3_constants.GW_FIP_KEY] = [] try: if deconfigure: self._process_router(ri) driver = self._drivermgr.get_driver(ri.device_id) driver.router_removed(ri) self._drivermgr.remove_driver(ri.router) #del self.service_instance[router_id] del self.router_dict[router_id] self.service_type[s_constants.VROUTER].remove(router_id) self.removed_services.discard(router_id) except svmt_exception.DriverException: LOG.warning(_LW("Router remove for service_id : %s was incomplete. " "Adding the router to removed_services list"), router_id) self.removed_services.add(router_id) # remove this router from updated_routers if it is there. It might # end up there too if exception was thrown earlier inside # `_process_router()` self.updated_services.discard(router_id) #ri.router[l3_constants.INTERFACE_KEY] = [] #ri.router[l3_constants.FLOATINGIP_KEY] = [] #ri.router[l3_constants.MANAGERMENT_KEY] = [] #ri.router[l3_constants.GW_INTERFACE_KEY] = [] #ri.router[l3_constants.GW_FIP_KEY] = [] def _process_router(self, ri): """Process a router, apply latest configuration and update router_info. Get the router dict from RouterInfo and proceed to detect changes from the last known state. When new ports or deleted ports are detected, `internal_network_added()` or `internal_networks_removed()` are called accordingly. Similarly changes in ex_gw_ports causes `external_gateway_added()` or `external_gateway_removed()` calls. Next, floating_ips and routes are processed. Also, latest state is stored in ri.internal_ports and ri.ex_gw_ports for future comparisons. :param ri : RouterInfo object of the router being processed. :return:None :raises: networking_cisco.plugins.cisco.cfg_agent.cfg_exceptions.DriverException if the configuration operation fails. """ try: ex_gw_ports = ri.router.get(l3_constants.GW_INTERFACE_KEY, []) internal_ports = ri.router.get(l3_constants.INTERFACE_KEY, []) mgmt_ports = ri.router.get(l3_constants.MANAGERMENT_KEY, []) ex_gw_fips = ri.router.get(l3_constants.GW_FIP_KEY, []) existing_port_ids = set([p['id'] for p in ri.internal_ports]) current_port_ids = set([p['id'] for p in internal_ports if p['admin_state_up']]) new_ports = [p for p in internal_ports if p['id'] in (current_port_ids - existing_port_ids)] old_ports = [p for p in ri.internal_ports if p['id'] not in current_port_ids] for p in new_ports: self._set_subnet_info(p) self._internal_network_added(ri, p, ex_gw_ports, ex_gw_fips) ri.internal_ports.append(p) for p in old_ports: self._internal_network_removed(ri, p, ri.ex_gw_ports, ri.ex_gw_fips) ri.internal_ports.remove(p) if ex_gw_ports and ex_gw_fips and ex_gw_fips != ri.ex_gw_fips: #TODO select the first ex gw port self._set_subnet_info(ex_gw_ports) self._external_gateway_added(ri, ex_gw_fips, ex_gw_ports) elif ex_gw_ports and not ex_gw_fips and ex_gw_fips != ri.ex_gw_fips: self._external_gateway_removed(ri, ri.ex_gw_fips, ex_gw_ports) if ex_gw_ports: self._process_router_floating_ips(ri, ex_gw_ports) ri.ex_gw_ports = ex_gw_ports ri.mgmt_ports = mgmt_ports ri.ex_gw_fips = ex_gw_fips #hxn #self._routes_updated(ri) except svmt_exception.DriverException as e: with excutils.save_and_reraise_exception(): self.updated_services.update(ri.router_id) LOG.error(e) def _process_router_floating_ips(self, ri, ex_gw_ports): """Process a router's floating ips. Compare current floatingips (in ri.floating_ips) with the router's updated floating ips (in ri.router.floating_ips) and detect flaoting_ips which were added or removed. Notify driver of the change via `floating_ip_added()` or `floating_ip_removed()`. :param ri: RouterInfo object of the router being processed. :param ex_gw_ports: Port dict of the external gateway port. :return: None :raises: networking_cisco.plugins.cisco.cfg_agent.cfg_exceptions. DriverException if the configuration operation fails. """ floating_ips = ri.router.get(l3_constants.FLOATINGIP_KEY, []) existing_floating_ip_ids = set( [fip['id'] for fip in ri.floating_ips]) cur_floating_ip_ids = set([fip['id'] for fip in floating_ips]) id_to_fip_map = {} for fip in floating_ips: if fip['port_id']: # store to see if floatingip was remapped id_to_fip_map[fip['id']] = fip if fip['id'] not in existing_floating_ip_ids: ri.floating_ips.append(fip) self._floating_ip_added(ri, ex_gw_ports, fip['floating_ip_address'], fip['rate_limit'], fip['fixed_ip_address']) floating_ip_ids_to_remove = (existing_floating_ip_ids - cur_floating_ip_ids) for fip in ri.floating_ips: if fip['id'] in floating_ip_ids_to_remove: ri.floating_ips.remove(fip) self._floating_ip_removed(ri, ri.ex_gw_ports, fip['floating_ip_address'], fip['fixed_ip_address']) else: # handle remapping of a floating IP new_fip = id_to_fip_map[fip['id']] new_fixed_ip = new_fip['fixed_ip_address'] new_rate_limit = new_fip['rate_limit'] existing_fixed_ip = fip['fixed_ip_address'] existing_rate_limit = fip['rate_limit'] if (new_fixed_ip and existing_fixed_ip and new_fixed_ip != existing_fixed_ip) or ( new_rate_limit != existing_rate_limit): floating_ip = fip['floating_ip_address'] self._floating_ip_removed(ri, ri.ex_gw_ports, floating_ip, existing_fixed_ip) self._floating_ip_added(ri, ri.ex_gw_ports, floating_ip, rate_limit,new_fixed_ip) ri.floating_ips.remove(fip) ri.floating_ips.append(new_fip) def _internal_network_added(self, ri, port, ex_gw_ports, ex_gw_fips): try: driver = self._drivermgr.get_driver(ri.device_id) driver.internal_network_added(ri, port) if ri.snat_enabled and ex_gw_ports: driver.enable_internal_network_NAT(ri, port, ex_gw_ports, ex_gw_fips) except Exception: with excutils.save_and_reraise_exception(): LOG.error("driver config fail ") def _internal_network_removed(self, ri, port, ex_gw_ports, ex_gw_fips): try: driver = self._drivermgr.get_driver(ri.device_id) driver.internal_network_removed(ri, port) if ri.snat_enabled and ex_gw_ports: driver.disable_internal_network_NAT(ri, port, ex_gw_ports, ex_gw_fips) except Exception: with excutils.save_and_reraise_exception(): LOG.error("driver config fail ") def _external_gateway_added(self, ri, ex_gw_fips, ex_gw_ports): try: driver = self._drivermgr.get_driver(ri.device_id) driver.external_gateway_added(ri, ex_gw_fips, ex_gw_ports) if ri.snat_enabled and ri.internal_ports: for port in ri.internal_ports: driver.enable_internal_network_NAT(ri, port, ex_gw_ports, ex_gw_fips) except Exception: with excutils.save_and_reraise_exception(): LOG.error("driver config fail ") def _external_gateway_removed(self, ri, ex_gw_fips, ex_gw_ports): try: driver = self._drivermgr.get_driver(ri.device_id) if ri.snat_enabled and ri.internal_ports: for port in ri.internal_ports: driver.disable_internal_network_NAT(ri, port, ex_gw_ports, ex_gw_fips) driver.external_gateway_removed(ri, ex_gw_fips, ex_gw_ports) except Exception: with excutils.save_and_reraise_exception(): LOG.error("driver config fail ") def _floating_ip_added(self, ri, ex_gw_ports, floating_ip, rate_limit, fixed_ip): try: driver = self._drivermgr.get_driver(ri.device_id) driver.floating_ip_added(ri, ex_gw_ports, floating_ip, rate_limit, fixed_ip) except Exception: with excutils.save_and_reraise_exception(): LOG.error("driver config fail ") def _floating_ip_removed(self, ri, ex_gw_ports, floating_ip, fixed_ip ): try: driver = self._drivermgr.get_driver(ri.device_id) driver.floating_ip_removed(ri, ex_gw_ports, floating_ip, fixed_ip) except Exception: with excutils.save_and_reraise_exception(): LOG.error("driver config fail ") def _sync_device(self): try: for driver in self._drivermgr.get_drivers().values(): driver.sync_device() except Exception: with excutils.save_and_reraise_exception(): LOG.error("sync device error") def _routes_updated(self, ri): """Update the state of routes in the router. Compares the current routes with the (configured) existing routes and detect what was removed or added. Then configure the logical router in the hosting device accordingly. :param ri: RouterInfo corresponding to the router. :return: None :raises: networking_cisco.plugins.cisco.cfg_agent.cfg_exceptions.DriverException if the configuration operation fails. """ new_routes = ri.router['routes'] old_routes = ri.routes adds, removes = common_utils.diff_list_of_dict(old_routes, new_routes) for route in adds: LOG.debug("Added route entry is '%s'", route) # remove replaced route from deleted route for del_route in removes: if route['destination'] == del_route['destination']: removes.remove(del_route) driver = self._drivermgr.get_driver(ri.device_id) driver.routes_updated(ri, 'replace', route) for route in removes: LOG.debug("Removed route entry is '%s'", route) driver = self._drivermgr.get_driver(ri.device_id) driver.routes_updated(ri, 'delete', route) ri.routes = new_routes @staticmethod def _set_subnet_info(port): ips = port['fixed_ips'] if not ips: raise Exception(_("Router port %s has no IP address") % port['id']) if len(ips) > 1: LOG.error(_LE("Ignoring multiple IPs on router port %s"), port['id']) prefixlen = netaddr.IPNetwork(port['subnet']['cidr']).prefixlen port['ip_cidr'] = "%s/%s" % (ips[0]['ip_address'], prefixlen)
""" Django settings for mysite project. Generated by 'django-admin startproject' using Django 1.10.3. For more information on this file, see https://docs.djangoproject.com/en/1.10/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.10/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'i%06y2q&4l-!nv*8oolv470b!o)!xg*^9f7^d=q10#b$wd%c_e' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'mysite.core', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'mysite.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'mysite/templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'mysite.wsgi.application' # Database # https://docs.djangoproject.com/en/1.10/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Internationalization # https://docs.djangoproject.com/en/1.10/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.10/howto/static-files/ STATIC_URL = '/static/' LOGIN_URL = 'login' LOGOUT_URL = 'logout' LOGIN_REDIRECT_URL = 'home' EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
import React, { Component } from "react"; import AutoComplete from 'material-ui/AutoComplete'; export default class Search extends Component{ render(){ const { mangas } = this.props; return (<div> <AutoComplete hintText="Search a manga" dataSource={mangas} dataSourceConfig={{text: 'name', value:'mangaId'}} onNewRequest={this.props.update} filter={AutoComplete.caseInsensitiveFilter} maxSearchResults={20} open={false} /> </div> ); } }
# Copyright 2012 Managed I.T. # # Author: Kiall Mac Innes <[email protected]> # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from designate.api import service from designate.tests.test_api import ApiTestCase class ApiServiceTest(ApiTestCase): def setUp(self): super(ApiServiceTest, self).setUp() self.config(listen=['0.0.0.0:0'], group='service:api') self.service = service.Service() def test_start_and_stop(self): # NOTE: Start is already done by the fixture in start_service() self.service.start() self.service.stop()
'use strict'; describe('weather.dash module', function() { describe('weather controller', function(){ var scope, dashCtrl, $httpBackend; beforeEach(module('weather.dash', 'mockedFeed')); beforeEach(inject(function(_$httpBackend_, $rootScope, $controller, mockedJSON) { $httpBackend = _$httpBackend_; $httpBackend.expectGET(new RegExp('https://thingspeak.com/channels/22967/feeds.json*')). respond(mockedJSON); scope = $rootScope.$new(); dashCtrl = $controller('DashCtrl', {$scope: scope}); })); it('should ....', function() { expect(dashCtrl).toBeDefined(); }); it('should create "channel" model', function() { expect(scope.channel).toBeUndefined(); $httpBackend.flush(); expect(scope.channel).toBeDefined(); expect(scope.channel.id).toBeDefined(); }); it('should create "feeds" model with list of feed items', function() { expect(scope.feeds).toBeUndefined(); $httpBackend.flush(); expect(scope.feeds).toBeDefined(); expect(scope.feeds[0].field1).toEqual('69'); expect(scope.feeds[0].field2).toEqual('49'); }); it('should set feedLoaded to true after data load', function() { expect(scope.feedLoaded).toBeUndefined(); $httpBackend.flush(); expect(scope.feedLoaded).toBeDefined(); expect(scope.feedLoaded).toEqual(true); }) }); });
import React from 'react'; import Up from 'grommet/components/icons/base/Up'; import Button from 'grommet/components/Button'; import Box from 'grommet/components/Box'; const CLASS_ROOT = 'infographic__button'; export default function EndButton (props) { return ( <Button plain={true} className={`${CLASS_ROOT} ${CLASS_ROOT}--end`} onClick={props.onClick}> <Box direction="column" align="center" justify="center"> <span className={`${CLASS_ROOT}-icon`}> <Up a11yTitle={'Scroll to top'} onClick={props.onClick} /> </span> </Box> </Button> ); }
/** * Created by zhengxiaoyong on 16/4/18. * * native结果数据返回格式: * var resultData = { status: { code: 0,//0成功,1失败 msg: '请求超时'//失败时候的提示,成功可为空 }, data: {}//数据,无数据可以为空 }; 协定协议:rainbow://class:port/method?params; params是一串json字符串 */ (function () { var doc = document; var win = window; var ua = win.navigator.userAgent; var JS_BRIDGE_PROTOCOL_SCHEMA = "rainbow"; var increase = 1; var RainbowBridge = win.RainbowBridge || (win.RainbowBridge = {}); var ExposeMethod = { callMethod: function (clazz, method, param, callback) { var port = PrivateMethod.generatePort(); if (typeof callback !== 'function') { callback = null; } PrivateMethod.registerCallback(port, callback); PrivateMethod.callNativeMethod(clazz, port, method, param); }, onComplete: function (port, result) { PrivateMethod.onNativeComplete(port, result); } }; var PrivateMethod = { callbacks: {}, registerCallback: function (port, callback) { if (callback) { PrivateMethod.callbacks[port] = callback; } }, getCallback: function (port) { var call = {}; if (PrivateMethod.callbacks[port]) { call.callback = PrivateMethod.callbacks[port]; } else { call.callback = null; } return call; }, unRegisterCallback: function (port) { if (PrivateMethod.callbacks[port]) { delete PrivateMethod.callbacks[port]; } }, onNativeComplete: function (port, result) { var resultJson = PrivateMethod.str2Json(result); var callback = PrivateMethod.getCallback(port).callback; PrivateMethod.unRegisterCallback(port); if (callback) { //执行回调 callback && callback(resultJson); } }, generatePort: function () { return Math.floor(Math.random() * (1 << 50)) + '' + increase++; }, str2Json: function (str) { if (str && typeof str === 'string') { try { return JSON.parse(str); } catch (e) { return { status: { code: 1, msg: 'params parse error!' } }; } } else { return str || {}; } }, json2Str: function (param) { if (param && typeof param === 'object') { return JSON.stringify(param); } else { return param || ''; } }, callNativeMethod: function (clazz, port, method, param) { if (PrivateMethod.isAndroid()) { var jsonStr = PrivateMethod.json2Str(param); var uri = JS_BRIDGE_PROTOCOL_SCHEMA + "://" + clazz + ":" + port + "/" + method + "?" + jsonStr; win.prompt(uri, ""); } }, isAndroid: function () { var tmp = ua.toLowerCase(); var android = tmp.indexOf("android") > -1; return !!android; }, isIos: function () { var tmp = ua.toLowerCase(); var ios = tmp.indexOf("iphone") > -1; return !!ios; } }; for (var index in ExposeMethod) { if (ExposeMethod.hasOwnProperty(index)) { if (!Object.prototype.hasOwnProperty.call(RainbowBridge, index)) { RainbowBridge[index] = ExposeMethod[index]; } } } })();
import React from "react"; import { useSelector, useDispatch } from "react-redux"; import { fetchAsync, prayerCard, comingPrayer } from "./prayersSlice"; import PrayerCard from "./PrayerCard"; import useRemaining from "../hooks/useRemaining"; export default function Prayers() { const dispatch = useDispatch(); const prayers = useSelector(prayerCard); const nextPrayer = useSelector(comingPrayer); const remainingToPrayer = useRemaining(nextPrayer); React.useEffect(() => { dispatch(fetchAsync("http://127.0.0.1:8001/mozn/api/today")); }, [dispatch]); return <PrayerCard prayers={prayers} remainingToPrayer={remainingToPrayer} />; }
from datetime import timedelta import pytest from django.urls import reverse from django.utils import timezone from rest_framework import status from saec.core.models import ComunicacaoAgendada URL = reverse('agendamento-list') UMA_DATA_FUTURA = (timezone.now() + timedelta(days=1)).strftime('%Y-%m-%d %H:%M:%S.%f') UMA_DATA_PASSADA = (timezone.now() - timedelta(days=30)).strftime('%Y-%m-%d %H:%M:%S.%f') @pytest.fixture def agendamento(): return { "data": UMA_DATA_FUTURA, "mensagem": "Bom dia!", "para": "[email protected]", "via": "email", } def test_post_agendamento(api_client, agendamento): resp = api_client().post( URL, agendamento, format='json', ) assert resp.status_code == status.HTTP_201_CREATED def test_delete_cancela_agendamento(api_client, agendamento): # given: resp = api_client().post(URL, agendamento, format='json') detail_url = reverse('agendamento-detail', kwargs={'pk': str(resp.data['id'])}) # when resp = api_client().delete(detail_url) # then assert resp.status_code == status.HTTP_204_NO_CONTENT # and resp = api_client().get(detail_url) assert resp.status_code == status.HTTP_200_OK assert resp.data['status'] == ComunicacaoAgendada.Status.CANCELADA def test_data_de_agendmento_nao_futura(api_client, agendamento): # given agendamento = agendamento.copy() agendamento['data'] = UMA_DATA_PASSADA # when resp = api_client().post( URL, agendamento, format='json', ) # then assert resp.status_code == status.HTTP_400_BAD_REQUEST @pytest.mark.parametrize('para,via', ( ("nao é um endereço de email!", "email"), ("não é um telefone", "sms"), ("não é um telefone", "whatsapp"), # ("", "push"), # existe um formato? pode ser qualquer coisa?? )) def test_destino_correspondente_deve_ser_informado(api_client, agendamento, via, para): # given agendamento = agendamento.copy() agendamento['para'] = para agendamento['via'] = via # when resp = api_client().post( URL, agendamento, format='json', ) # then assert resp.status_code == status.HTTP_400_BAD_REQUEST def test_atualizacao_do_agendaento_nao_eh_permitida(api_client, agendamento): """Se relamente necessário, CANCELE (DELETE) o agendamento e envie um novo""" # given agendamento = agendamento.copy() mensagem_corrigida = 'mensagem corrigida' agendamento['name'] = mensagem_corrigida # when resp = api_client().put( URL, agendamento, format='json', ) # then assert resp.status_code == status.HTTP_405_METHOD_NOT_ALLOWED
// jslint.js // 2009-10-04 /* Copyright (c) 2002 Douglas Crockford (www.JSLint.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The Software shall be used for Good, not Evil. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ module('lively.jslint').requires().toRun(function() { /* JSLINT is a global function. It takes two parameters. var myResult = JSLINT(source, option); The first parameter is either a string or an array of strings. If it is a string, it will be split on '\n' or '\r'. If it is an array of strings, it is assumed that each string represents one line. The source can be a JavaScript text, or HTML text, or a Konfabulator text. The second parameter is an optional object of options which control the operation of JSLINT. Most of the options are booleans: They are all are optional and have a default value of false. If it checks out, JSLINT returns true. Otherwise, it returns false. If false, you can inspect JSLINT.errors to find out the problems. JSLINT.errors is an array of objects containing these members: { line : The line (relative to 0) at which the lint was found character : The character (relative to 0) at which the lint was found reason : The problem evidence : The text line in which the problem occurred raw : The raw message before the details were inserted a : The first detail b : The second detail c : The third detail d : The fourth detail } If a fatal error was found, a null will be the last element of the JSLINT.errors array. You can request a Function Report, which shows all of the functions and the parameters and vars that they use. This can be used to find implied global variables and other problems. The report is in HTML and can be inserted in an HTML <body>. var myReport = JSLINT.report(limited); If limited is true, then the report will be limited to only errors. You can request a data structure which contains JSLint's results. var myData = JSLINT.data(); It returns a structure with this form: { errors: [ { line: NUMBER, character: NUMBER, reason: STRING, evidence: STRING } ], functions: [ name: STRING, line: NUMBER, last: NUMBER, param: [ STRING ], closure: [ STRING ], var: [ STRING ], exception: [ STRING ], outer: [ STRING ], unused: [ STRING ], global: [ STRING ], label: [ STRING ] ], globals: [ STRING ], member: { STRING: NUMBER }, unuseds: [ { name: STRING, line: NUMBER } ], implieds: [ { name: STRING, line: NUMBER } ], urls: [ STRING ], json: BOOLEAN } Empty arrays will not be included. */ /*jslint evil: true, nomen: false, onevar: false, regexp: false, strict: true */ /*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%", "(begin)", "(breakage)", "(context)", "(error)", "(global)", "(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)", "(params)", "(scope)", "(verb)", "*", "+", "++", "-", "--", "\/", "<", "<=", "==", "===", ">", ">=", ADSAFE, Array, Boolean, COM, Canvas, CustomAnimation, Date, Debug, E, Error, EvalError, FadeAnimation, Flash, FormField, Frame, Function, HotKey, Image, JSON, LN10, LN2, LOG10E, LOG2E, MAX_VALUE, MIN_VALUE, Math, MenuItem, MoveAnimation, NEGATIVE_INFINITY, Number, Object, Option, PI, POSITIVE_INFINITY, Point, RangeError, Rectangle, ReferenceError, RegExp, ResizeAnimation, RotateAnimation, SQRT1_2, SQRT2, ScrollBar, String, Style, SyntaxError, System, Text, TextArea, Timer, TypeError, URIError, URL, Web, Window, XMLDOM, XMLHttpRequest, "\\", a, abbr, acronym, addEventListener, address, adsafe, alert, aliceblue, animator, antiquewhite, appleScript, applet, apply, approved, aqua, aquamarine, area, arguments, arity, autocomplete, azure, b, background, "background-attachment", "background-color", "background-image", "background-position", "background-repeat", base, bdo, beep, beige, big, bisque, bitwise, black, blanchedalmond, block, blockquote, blue, blueviolet, blur, body, border, "border-bottom", "border-bottom-color", "border-bottom-style", "border-bottom-width", "border-collapse", "border-color", "border-left", "border-left-color", "border-left-style", "border-left-width", "border-right", "border-right-color", "border-right-style", "border-right-width", "border-spacing", "border-style", "border-top", "border-top-color", "border-top-style", "border-top-width", "border-width", bottom, br, brown, browser, burlywood, button, bytesToUIString, c, cadetblue, call, callee, caller, canvas, cap, caption, "caption-side", cases, center, charAt, charCodeAt, character, chartreuse, chocolate, chooseColor, chooseFile, chooseFolder, cite, clear, clearInterval, clearTimeout, clip, close, closeWidget, closed, closure, cm, code, col, colgroup, color, comment, condition, confirm, console, constructor, content, convertPathToHFS, convertPathToPlatform, coral, cornflowerblue, cornsilk, "counter-increment", "counter-reset", create, crimson, css, cursor, cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise, darkviolet, data, dd, debug, decodeURI, decodeURIComponent, deeppink, deepskyblue, defaultStatus, defineClass, del, deserialize, dfn, dimension, dimgray, dir, direction, display, div, dl, document, dodgerblue, dt, edition, else, em, embed, empty, "empty-cells", encodeURI, encodeURIComponent, entityify, eqeqeq, errors, escape, eval, event, evidence, evil, ex, exception, exec, exps, fieldset, filesystem, firebrick, first, float, floor, floralwhite, focus, focusWidget, font, "font-face", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", forestgreen, forin, form, fragment, frame, frames, frameset, from, fromCharCode, fuchsia, fud, funct, function, functions, g, gainsboro, gc, getComputedStyle, ghostwhite, global, globals, gold, goldenrod, gray, green, greenyellow, h1, h2, h3, h4, h5, h6, hasOwnProperty, head, height, help, history, honeydew, hotpink, hr, html, i, iTunes, id, identifier, iframe, img, immed, implieds, in, include, indent, indexOf, indianred, indigo, init, input, ins, isAlpha, isApplicationRunning, isDigit, isFinite, isNaN, ivory, join, jslint, json, kbd, khaki, konfabulatorVersion, label, labelled, lang, last, lavender, lavenderblush, lawngreen, laxbreak, lbp, led, left, legend, lemonchiffon, length, "letter-spacing", li, lib, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightsteelblue, lightyellow, lime, limegreen, line, "line-height", linen, link, "list-style", "list-style-image", "list-style-position", "list-style-type", load, loadClass, location, log, m, magenta, map, margin, "margin-bottom", "margin-left", "margin-right", "margin-top", "marker-offset", maroon, match, "max-height", "max-width", maxerr, maxlen, md5, media, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, member, menu, message, meta, midnightblue, "min-height", "min-width", mintcream, mistyrose, mm, moccasin, moveBy, moveTo, name, navajowhite, navigator, navy, new, newcap, noframes, nomen, noscript, nud, object, ol, oldlace, olive, olivedrab, on, onbeforeunload, onblur, onerror, onevar, onfocus, onload, onresize, onunload, opacity, open, openURL, opener, opera, optgroup, option, orange, orangered, orchid, outer, outline, "outline-color", "outline-style", "outline-width", overflow, "overflow-x", "overflow-y", p, padding, "padding-bottom", "padding-left", "padding-right", "padding-top", page, "page-break-after", "page-break-before", palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, param, parent, parseFloat, parseInt, passfail, pc, peachpuff, peru, pink, play, plum, plusplus, pop, popupMenu, position, powderblue, pre, predef, preferenceGroups, preferences, print, prompt, prototype, pt, purple, push, px, q, quit, quotes, random, range, raw, reach, readFile, readUrl, reason, red, regexp, reloadWidget, removeEventListener, replace, report, reserved, resizeBy, resizeTo, resolvePath, resumeUpdates, rhino, right, rosybrown, royalblue, runCommand, runCommandInBg, saddlebrown, safe, salmon, samp, sandybrown, saveAs, savePreferences, screen, script, scroll, scrollBy, scrollTo, seagreen, seal, search, seashell, select, serialize, setInterval, setTimeout, shift, showWidgetPreferences, sidebar, sienna, silver, skyblue, slateblue, slategray, sleep, slice, small, snow, sort, span, spawn, speak, split, springgreen, src, status, steelblue, strict, strong, style, styleproperty, sub, substr, sup, supplant, suppressUpdates, sync, system, table, "table-layout", tan, tbody, td, teal, tellWidget, test, "text-align", "text-decoration", "text-indent", "text-shadow", "text-transform", textarea, tfoot, th, thead, thistle, title, toLowerCase, toString, toUpperCase, toint32, token, tomato, top, tr, tt, turquoise, type, u, ul, undef, unescape, "unicode-bidi", unused, unwatch, updateNow, urls, value, valueOf, var, version, "vertical-align", violet, visibility, watch, wheat, white, "white-space", whitesmoke, widget, width, "word-spacing", "word-wrap", yahooCheckLogin, yahooLogin, yahooLogout, yellow, yellowgreen, "z-index" */ // We build the application inside a function so that we produce only a single // global variable. The function will be invoked, its return value is the JSLINT // application itself. "use strict"; var JSLINT = (function () { var adsafe_id, // The widget's ADsafe id. adsafe_may, // The widget may load approved scripts. adsafe_went, // ADSAFE.go has been called. anonname, // The guessed name for anonymous functions. approved, // ADsafe approved urls. atrule = { media : true, 'font-face': true, page : true }, // These are operators that should not be used with the ! operator. bang = { '<': true, '<=': true, '==': true, '===': true, '!==': true, '!=': true, '>': true, '>=': true, '+': true, '-': true, '*': true, '/': true, '%': true }, // These are members that should not be permitted in the safe subset. banned = { // the member names that ADsafe prohibits. 'arguments' : true, callee : true, caller : true, constructor : true, 'eval' : true, prototype : true, unwatch : true, valueOf : true, watch : true }, // These are the JSLint boolean options. boolOptions = { adsafe : true, // if ADsafe should be enforced bitwise : true, // if bitwise operators should not be allowed browser : true, // if the standard browser globals should be predefined cap : true, // if upper case HTML should be allowed css : true, // if CSS workarounds should be tolerated debug : true, // if debugger statements should be allowed eqeqeq : true, // if === should be required evil : true, // if eval should be allowed forin : true, // if for in statements must filter fragment : true, // if HTML fragments should be allowed immed : true, // if immediate invocations must be wrapped in parens laxbreak : true, // if line breaks should not be checked newcap : true, // if constructor names must be capitalized nomen : true, // if names should be checked on : true, // if HTML event handlers should be allowed onevar : true, // if only one var statement per function should be allowed passfail : true, // if the scan should stop on first error plusplus : true, // if increment/decrement should not be allowed regexp : true, // if the . should not be allowed in regexp literals rhino : true, // if the Rhino environment globals should be predefined undef : true, // if variables should be declared before used safe : true, // if use of some browser features should be restricted sidebar : true, // if the System object should be predefined strict : true, // require the "use strict"; pragma sub : true, // if all forms of subscript notation are tolerated white : true, // if strict whitespace rules apply widget : true // if the Yahoo Widgets globals should be predefined }, // browser contains a set of global names which are commonly provided by a // web browser environment. browser = { addEventListener: false, alert : false, blur : false, clearInterval : false, clearTimeout : false, close : false, closed : false, confirm : false, console : false, Debug : false, defaultStatus : false, document : false, event : false, focus : false, frames : false, getComputedStyle: false, history : false, Image : false, length : false, location : false, moveBy : false, moveTo : false, name : false, navigator : false, onbeforeunload : true, onblur : true, onerror : true, onfocus : true, onload : true, onresize : true, onunload : true, open : false, opener : false, opera : false, Option : false, parent : false, print : false, prompt : false, removeEventListener: false, resizeBy : false, resizeTo : false, screen : false, scroll : false, scrollBy : false, scrollTo : false, setInterval : false, setTimeout : false, status : false, top : false, XMLHttpRequest : false }, cssAttributeData, cssAny, cssColorData = { "aliceblue" : true, "antiquewhite" : true, "aqua" : true, "aquamarine" : true, "azure" : true, "beige" : true, "bisque" : true, "black" : true, "blanchedalmond" : true, "blue" : true, "blueviolet" : true, "brown" : true, "burlywood" : true, "cadetblue" : true, "chartreuse" : true, "chocolate" : true, "coral" : true, "cornflowerblue" : true, "cornsilk" : true, "crimson" : true, "cyan" : true, "darkblue" : true, "darkcyan" : true, "darkgoldenrod" : true, "darkgray" : true, "darkgreen" : true, "darkkhaki" : true, "darkmagenta" : true, "darkolivegreen" : true, "darkorange" : true, "darkorchid" : true, "darkred" : true, "darksalmon" : true, "darkseagreen" : true, "darkslateblue" : true, "darkslategray" : true, "darkturquoise" : true, "darkviolet" : true, "deeppink" : true, "deepskyblue" : true, "dimgray" : true, "dodgerblue" : true, "firebrick" : true, "floralwhite" : true, "forestgreen" : true, "fuchsia" : true, "gainsboro" : true, "ghostwhite" : true, "gold" : true, "goldenrod" : true, "gray" : true, "green" : true, "greenyellow" : true, "honeydew" : true, "hotpink" : true, "indianred" : true, "indigo" : true, "ivory" : true, "khaki" : true, "lavender" : true, "lavenderblush" : true, "lawngreen" : true, "lemonchiffon" : true, "lightblue" : true, "lightcoral" : true, "lightcyan" : true, "lightgoldenrodyellow" : true, "lightgreen" : true, "lightpink" : true, "lightsalmon" : true, "lightseagreen" : true, "lightskyblue" : true, "lightslategray" : true, "lightsteelblue" : true, "lightyellow" : true, "lime" : true, "limegreen" : true, "linen" : true, "magenta" : true, "maroon" : true, "mediumaquamarine" : true, "mediumblue" : true, "mediumorchid" : true, "mediumpurple" : true, "mediumseagreen" : true, "mediumslateblue" : true, "mediumspringgreen" : true, "mediumturquoise" : true, "mediumvioletred" : true, "midnightblue" : true, "mintcream" : true, "mistyrose" : true, "moccasin" : true, "navajowhite" : true, "navy" : true, "oldlace" : true, "olive" : true, "olivedrab" : true, "orange" : true, "orangered" : true, "orchid" : true, "palegoldenrod" : true, "palegreen" : true, "paleturquoise" : true, "palevioletred" : true, "papayawhip" : true, "peachpuff" : true, "peru" : true, "pink" : true, "plum" : true, "powderblue" : true, "purple" : true, "red" : true, "rosybrown" : true, "royalblue" : true, "saddlebrown" : true, "salmon" : true, "sandybrown" : true, "seagreen" : true, "seashell" : true, "sienna" : true, "silver" : true, "skyblue" : true, "slateblue" : true, "slategray" : true, "snow" : true, "springgreen" : true, "steelblue" : true, "tan" : true, "teal" : true, "thistle" : true, "tomato" : true, "turquoise" : true, "violet" : true, "wheat" : true, "white" : true, "whitesmoke" : true, "yellow" : true, "yellowgreen" : true }, cssBorderStyle, cssBreak, cssLengthData = { '%': true, 'cm': true, 'em': true, 'ex': true, 'in': true, 'mm': true, 'pc': true, 'pt': true, 'px': true }, cssOverflow, escapes = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '/' : '\\/', '\\': '\\\\' }, funct, // The current function functionicity = [ 'closure', 'exception', 'global', 'label', 'outer', 'unused', 'var' ], functions, // All of the functions global, // The global scope htmltag = { a: {}, abbr: {}, acronym: {}, address: {}, applet: {}, area: {empty: true, parent: ' map '}, b: {}, base: {empty: true, parent: ' head '}, bdo: {}, big: {}, blockquote: {}, body: {parent: ' html noframes '}, br: {empty: true}, button: {}, canvas: {parent: ' body p div th td '}, caption: {parent: ' table '}, center: {}, cite: {}, code: {}, col: {empty: true, parent: ' table colgroup '}, colgroup: {parent: ' table '}, dd: {parent: ' dl '}, del: {}, dfn: {}, dir: {}, div: {}, dl: {}, dt: {parent: ' dl '}, em: {}, embed: {}, fieldset: {}, font: {}, form: {}, frame: {empty: true, parent: ' frameset '}, frameset: {parent: ' html frameset '}, h1: {}, h2: {}, h3: {}, h4: {}, h5: {}, h6: {}, head: {parent: ' html '}, html: {parent: '*'}, hr: {empty: true}, i: {}, iframe: {}, img: {empty: true}, input: {empty: true}, ins: {}, kbd: {}, label: {}, legend: {parent: ' fieldset '}, li: {parent: ' dir menu ol ul '}, link: {empty: true, parent: ' head '}, map: {}, menu: {}, meta: {empty: true, parent: ' head noframes noscript '}, noframes: {parent: ' html body '}, noscript: {parent: ' body head noframes '}, object: {}, ol: {}, optgroup: {parent: ' select '}, option: {parent: ' optgroup select '}, p: {}, param: {empty: true, parent: ' applet object '}, pre: {}, q: {}, samp: {}, script: {empty: true, parent: ' body div frame head iframe p pre span '}, select: {}, small: {}, span: {}, strong: {}, style: {parent: ' head ', empty: true}, sub: {}, sup: {}, table: {}, tbody: {parent: ' table '}, td: {parent: ' tr '}, textarea: {}, tfoot: {parent: ' table '}, th: {parent: ' tr '}, thead: {parent: ' table '}, title: {parent: ' head '}, tr: {parent: ' table tbody thead tfoot '}, tt: {}, u: {}, ul: {}, 'var': {} }, ids, // HTML ids implied, // Implied globals inblock, indent, jsonmode, lines, lookahead, member, membersOnly, nexttoken, noreach, option, predefined, // Global variables defined by option prereg, prevtoken, rhino = { defineClass : false, deserialize : false, gc : false, help : false, load : false, loadClass : false, print : false, quit : false, readFile : false, readUrl : false, runCommand : false, seal : false, serialize : false, spawn : false, sync : false, toint32 : false, version : false }, scope, // The current scope sidebar = { System : false }, src, stack, // standard contains the global names that are provided by the // ECMAScript standard. standard = { Array : false, Boolean : false, Date : false, decodeURI : false, decodeURIComponent : false, encodeURI : false, encodeURIComponent : false, Error : false, 'eval' : false, EvalError : false, Function : false, hasOwnProperty : false, isFinite : false, isNaN : false, JSON : false, Math : false, Number : false, Object : false, parseInt : false, parseFloat : false, RangeError : false, ReferenceError : false, RegExp : false, String : false, SyntaxError : false, TypeError : false, URIError : false }, standard_member = { E : true, LN2 : true, LN10 : true, LOG2E : true, LOG10E : true, PI : true, SQRT1_2 : true, SQRT2 : true, MAX_VALUE : true, MIN_VALUE : true, NEGATIVE_INFINITY : true, POSITIVE_INFINITY : true }, strict_mode, syntax = {}, tab, token, urls, warnings, // widget contains the global names which are provided to a Yahoo // (fna Konfabulator) widget. widget = { alert : true, animator : true, appleScript : true, beep : true, bytesToUIString : true, Canvas : true, chooseColor : true, chooseFile : true, chooseFolder : true, closeWidget : true, COM : true, convertPathToHFS : true, convertPathToPlatform : true, CustomAnimation : true, escape : true, FadeAnimation : true, filesystem : true, Flash : true, focusWidget : true, form : true, FormField : true, Frame : true, HotKey : true, Image : true, include : true, isApplicationRunning : true, iTunes : true, konfabulatorVersion : true, log : true, md5 : true, MenuItem : true, MoveAnimation : true, openURL : true, play : true, Point : true, popupMenu : true, preferenceGroups : true, preferences : true, print : true, prompt : true, random : true, Rectangle : true, reloadWidget : true, ResizeAnimation : true, resolvePath : true, resumeUpdates : true, RotateAnimation : true, runCommand : true, runCommandInBg : true, saveAs : true, savePreferences : true, screen : true, ScrollBar : true, showWidgetPreferences : true, sleep : true, speak : true, Style : true, suppressUpdates : true, system : true, tellWidget : true, Text : true, TextArea : true, Timer : true, unescape : true, updateNow : true, URL : true, Web : true, widget : true, Window : true, XMLDOM : true, XMLHttpRequest : true, yahooCheckLogin : true, yahooLogin : true, yahooLogout : true }, // xmode is used to adapt to the exceptions in html parsing. // It can have these states: // false .js script file // html // outer // script // style // scriptstring // styleproperty xmode, xquote, // unsafe comment or string ax = /@cc|<\/?|script|\]*s\]|<\s*!|&lt/i, // unsafe characters that are silently deleted by one or more browsers cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/, // token tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jslint|members?|global)?|=|\/)?|\*[\/=]?|\+[+=]?|-[\-=]?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/, // html token hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-]*|[0-9]+|--|.)/, // characters in strings that need escapement nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/, nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, // outer html token ox = /[>&]|<[\/!]?|--/, // star slash lx = /\*\/|\/\*/, // identifier ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/, // javascript url jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i, // url badness ux = /&|\+|\u00AD|\.\.|\/\*|%[^;]|base64|url|expression|data|mailto/i, // style sx = /^\s*([{:#%.=,>+\[\]@()"';]|\*=?|\$=|\|=|\^=|~=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/, ssx = /^\s*([@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|\d+(?:\.\d+)?|<\/)/, // attributes characters qx = /[^a-zA-Z0-9-_\/ ]/, // query characters for ids dx = /[\[\]\/\\"'*<>.&:(){}+=#]/, rx = { outer: hx, html: hx, style: sx, styleproperty: ssx }; function F() {} if (typeof Object.create !== 'function') { Object.create = function (o) { F.prototype = o; return new F(); }; } function is_own(object, name) { return Object.prototype.hasOwnProperty.call(object, name); } function combine(t, o) { var n; for (n in o) { if (is_own(o, n)) { t[n] = o[n]; } } } String.prototype.entityify = function () { return this. replace(/&/g, '&amp;'). replace(/</g, '&lt;'). replace(/>/g, '&gt;'); }; String.prototype.isAlpha = function () { return (this >= 'a' && this <= 'z\uffff') || (this >= 'A' && this <= 'Z\uffff'); }; String.prototype.isDigit = function () { return (this >= '0' && this <= '9'); }; String.prototype.supplant = function (o) { return this.replace(/\{([^{}]*)\}/g, function (a, b) { var r = o[b]; return typeof r === 'string' || typeof r === 'number' ? r : a; }); }; String.prototype.name = function () { // If the string looks like an identifier, then we can return it as is. // If the string contains no control characters, no quote characters, and no // backslash characters, then we can simply slap some quotes around it. // Otherwise we must also replace the offending characters with safe // sequences. if (ix.test(this)) { return this; } if (nx.test(this)) { return '"' + this.replace(nxg, function (a) { var c = escapes[a]; if (c) { return c; } return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4); }) + '"'; } return '"' + this + '"'; }; function assume() { if (!option.safe) { if (option.rhino) { combine(predefined, rhino); } if (option.browser || option.sidebar) { combine(predefined, browser); } if (option.sidebar) { combine(predefined, sidebar); } if (option.widget) { combine(predefined, widget); } } } // Produce an error warning. function quit(m, l, ch) { throw { name: 'JSLintError', line: l, character: ch, message: m + " (" + Math.floor((l / lines.length) * 100) + "% scanned)." }; } function warning(m, t, a, b, c, d) { var ch, l, w; t = t || nexttoken; if (t.id === '(end)') { // `~ t = token; } l = t.line || 0; ch = t.from || 0; w = { id: '(error)', raw: m, evidence: lines[l - 1] || '', line: l, character: ch, a: a, b: b, c: c, d: d }; w.reason = m.supplant(w); JSLINT.errors.push(w); if (option.passfail) { quit('Stopping. ', l, ch); } warnings += 1; if (warnings >= option.maxerr) { quit("Too many errors.", l, ch); } return w; } function warningAt(m, l, ch, a, b, c, d) { return warning(m, { line: l, from: ch }, a, b, c, d); } function error(m, t, a, b, c, d) { var w = warning(m, t, a, b, c, d); quit("Stopping, unable to continue.", w.line, w.character); } function errorAt(m, l, ch, a, b, c, d) { return error(m, { line: l, from: ch }, a, b, c, d); } // lexical analysis var lex = (function lex() { var character, from, line, s; // Private lex methods function nextLine() { var at; if (line >= lines.length) { return false; } character = 1; s = lines[line]; line += 1; at = s.search(/ \t/); if (at >= 0) { warningAt("Mixed spaces and tabs.", line, at + 1); } s = s.replace(/\t/g, tab); at = s.search(cx); if (at >= 0) { warningAt("Unsafe character.", line, at); } if (option.maxlen && option.maxlen < s.length) { warningAt("Line too long.", line, s.length); } return true; } // Produce a token object. The token inherits from a syntax symbol. function it(type, value) { var i, t; if (type === '(color)') { t = {type: type}; } else if (type === '(punctuator)' || (type === '(identifier)' && is_own(syntax, value))) { t = syntax[value] || syntax['(error)']; } else { t = syntax[type]; } t = Object.create(t); if (type === '(string)' || type === '(range)') { if (jx.test(value)) { warningAt("Script URL.", line, from); } } if (type === '(identifier)') { t.identifier = true; if (value === '__iterator__' || value === '__proto__') { errorAt("Reserved name '{a}'.", line, from, value); } else if (option.nomen && (value.charAt(0) === '_' || value.charAt(value.length - 1) === '_')) { warningAt("Unexpected {a} in '{b}'.", line, from, "dangling '_'", value); } } t.value = value; t.line = line; t.character = character; t.from = from; i = t.id; if (i !== '(endline)') { prereg = i && (('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) || i === 'return'); } return t; } // Public lex methods return { init: function (source) { if (typeof source === 'string') { lines = source. replace(/\r\n/g, '\n'). replace(/\r/g, '\n'). split('\n'); } else { lines = source; } line = 0; nextLine(); from = 1; }, range: function (begin, end) { var c, value = ''; from = character; if (s.charAt(0) !== begin) { errorAt("Expected '{a}' and instead saw '{b}'.", line, character, begin, s.charAt(0)); } for (;;) { s = s.slice(1); character += 1; c = s.charAt(0); switch (c) { case '': errorAt("Missing '{a}'.", line, character, c); break; case end: s = s.slice(1); character += 1; return it('(range)', value); case xquote: case '\\': warningAt("Unexpected '{a}'.", line, character, c); } value += c; } }, // token -- this is called by advance to get the next token. token: function () { var b, c, captures, d, depth, high, i, l, low, q, t; function match(x) { var r = x.exec(s), r1; if (r) { l = r[0].length; r1 = r[1]; c = r1.charAt(0); s = s.substr(l); from = character + l - r1.length; character += l; return r1; } } function string(x) { var c, j, r = ''; if (jsonmode && x !== '"') { warningAt("Strings must use doublequote.", line, character); } if (xquote === x || (xmode === 'scriptstring' && !xquote)) { return it('(punctuator)', x); } function esc(n) { var i = parseInt(s.substr(j + 1, n), 16); j += n; if (i >= 32 && i <= 126 && i !== 34 && i !== 92 && i !== 39) { warningAt("Unnecessary escapement.", line, character); } character += n; c = String.fromCharCode(i); } j = 0; for (;;) { while (j >= s.length) { j = 0; if (xmode !== 'html' || !nextLine()) { errorAt("Unclosed string.", line, from); } } c = s.charAt(j); if (c === x) { character += 1; s = s.substr(j + 1); return it('(string)', r, x); } if (c < ' ') { if (c === '\n' || c === '\r') { break; } warningAt("Control character in string: {a}.", line, character + j, s.slice(0, j)); } else if (c === xquote) { warningAt("Bad HTML string", line, character + j); } else if (c === '<') { if (option.safe && xmode === 'html') { warningAt("ADsafe string violation.", line, character + j); } else if (s.charAt(j + 1) === '/' && (xmode || option.safe)) { warningAt("Expected '<\\/' and instead saw '</'.", line, character); } else if (s.charAt(j + 1) === '!' && (xmode || option.safe)) { warningAt("Unexpected '<!' in a string.", line, character); } } else if (c === '\\') { if (xmode === 'html') { if (option.safe) { warningAt("ADsafe string violation.", line, character + j); } } else if (xmode === 'styleproperty') { j += 1; character += 1; c = s.charAt(j); if (c !== x) { warningAt("Escapement in style string.", line, character + j); } } else { j += 1; character += 1; c = s.charAt(j); switch (c) { case xquote: warningAt("Bad HTML string", line, character + j); break; case '\\': case '\'': case '"': case '/': break; case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'u': esc(4); break; case 'v': c = '\v'; break; case 'x': if (jsonmode) { warningAt("Avoid \\x-.", line, character); } esc(2); break; default: warningAt("Bad escapement.", line, character); } } } r += c; character += 1; j += 1; } } for (;;) { if (!s) { return it(nextLine() ? '(endline)' : '(end)', ''); } while (xmode === 'outer') { i = s.search(ox); if (i === 0) { break; } else if (i > 0) { character += 1; s = s.slice(i); break; } else { if (!nextLine()) { return it('(end)', ''); } } } t = match(rx[xmode] || tx); if (!t) { if (xmode === 'html') { return it('(error)', s.charAt(0)); } else { t = ''; c = ''; while (s && s < '!') { s = s.substr(1); } if (s) { errorAt("Unexpected '{a}'.", line, character, s.substr(0, 1)); } } } else { // identifier if (c.isAlpha() || c === '_' || c === '$') { return it('(identifier)', t); } // number if (c.isDigit()) { if (xmode !== 'style' && !isFinite(Number(t))) { warningAt("Bad number '{a}'.", line, character, t); } if (xmode !== 'style' && xmode !== 'styleproperty' && s.substr(0, 1).isAlpha()) { warningAt("Missing space after '{a}'.", line, character, t); } if (c === '0') { d = t.substr(1, 1); if (d.isDigit()) { if (token.id !== '.' && xmode !== 'styleproperty') { warningAt("Don't use extra leading zeros '{a}'.", line, character, t); } } else if (jsonmode && (d === 'x' || d === 'X')) { warningAt("Avoid 0x-. '{a}'.", line, character, t); } } if (t.substr(t.length - 1) === '.') { warningAt( "A trailing decimal point can be confused with a dot '{a}'.", line, character, t); } return it('(number)', t); } switch (t) { // string case '"': case "'": return string(t); // // comment case '//': if (src || (xmode && xmode !== 'script')) { warningAt("Unexpected comment.", line, character); } else if (xmode === 'script' && /<\s*\//i.test(s)) { warningAt("Unexpected <\/ in comment.", line, character); } else if ((option.safe || xmode === 'script') && ax.test(s)) { warningAt("Dangerous comment.", line, character); } s = ''; token.comment = true; break; // /* comment case '/*': if (src || (xmode && xmode !== 'script' && xmode !== 'style' && xmode !== 'styleproperty')) { warningAt("Unexpected comment.", line, character); } if (option.safe && ax.test(s)) { warningAt("ADsafe comment violation.", line, character); } for (;;) { i = s.search(lx); if (i >= 0) { break; } if (!nextLine()) { errorAt("Unclosed comment.", line, character); } else { if (option.safe && ax.test(s)) { warningAt("ADsafe comment violation.", line, character); } } } character += i + 2; if (s.substr(i, 1) === '/') { errorAt("Nested comment.", line, character); } s = s.substr(i + 2); token.comment = true; break; // /*members /*jslint /*global case '/*members': case '/*member': case '/*jslint': case '/*global': case '*/': return { value: t, type: 'special', line: line, character: character, from: from }; case '': break; // / case '/': if (prereg) { depth = 0; captures = 0; l = 0; for (;;) { b = true; c = s.charAt(l); l += 1; switch (c) { case '': errorAt("Unclosed regular expression.", line, from); return; case '/': if (depth > 0) { warningAt("Unescaped '{a}'.", line, from + l, '/'); } c = s.substr(0, l - 1); q = { g: true, i: true, m: true }; while (q[s.charAt(l)] === true) { q[s.charAt(l)] = false; l += 1; } character += l; s = s.substr(l); return it('(regexp)', c); case '\\': c = s.charAt(l); if (c < ' ') { warningAt("Unexpected control character in regular expression.", line, from + l); } else if (c === '<') { warningAt("Unexpected escaped character '{a}' in regular expression.", line, from + l, c); } l += 1; break; case '(': depth += 1; b = false; if (s.charAt(l) === '?') { l += 1; switch (s.charAt(l)) { case ':': case '=': case '!': l += 1; break; default: warningAt("Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l)); } } else { captures += 1; } break; case '|': b = false; break; case ')': if (depth === 0) { warningAt("Unescaped '{a}'.", line, from + l, ')'); } else { depth -= 1; } break; case ' ': q = 1; while (s.charAt(l) === ' ') { l += 1; q += 1; } if (q > 1) { warningAt("Spaces are hard to count. Use {{a}}.", line, from + l, q); } break; case '[': c = s.charAt(l); if (c === '^') { l += 1; if (option.regexp) { warningAt("Insecure '{a}'.", line, from + l, c); } } q = false; if (c === ']') { warningAt("Empty class.", line, from + l - 1); q = true; } klass: do { c = s.charAt(l); l += 1; switch (c) { case '[': case '^': warningAt("Unescaped '{a}'.", line, from + l, c); q = true; break; case '-': if (q) { q = false; } else { warningAt("Unescaped '{a}'.", line, from + l, '-'); q = true; } break; case ']': if (!q) { warningAt("Unescaped '{a}'.", line, from + l - 1, '-'); } break klass; case '\\': c = s.charAt(l); if (c < ' ') { warningAt("Unexpected control character in regular expression.", line, from + l); } else if (c === '<') { warningAt("Unexpected escaped character '{a}' in regular expression.", line, from + l, c); } l += 1; q = true; break; case '/': warningAt("Unescaped '{a}'.", line, from + l - 1, '/'); q = true; break; case '<': if (xmode === 'script') { c = s.charAt(l); if (c === '!' || c === '/') { warningAt("HTML confusion in regular expression '<{a}'.", line, from + l, c); } } q = true; break; default: q = true; } } while (c); break; case '.': if (option.regexp) { warningAt("Insecure '{a}'.", line, from + l, c); } break; case ']': case '?': case '{': case '}': case '+': case '*': warningAt("Unescaped '{a}'.", line, from + l, c); break; case '<': if (xmode === 'script') { c = s.charAt(l); if (c === '!' || c === '/') { warningAt("HTML confusion in regular expression '<{a}'.", line, from + l, c); } } } if (b) { switch (s.charAt(l)) { case '?': case '+': case '*': l += 1; if (s.charAt(l) === '?') { l += 1; } break; case '{': l += 1; c = s.charAt(l); if (c < '0' || c > '9') { warningAt("Expected a number and instead saw '{a}'.", line, from + l, c); } l += 1; low = +c; for (;;) { c = s.charAt(l); if (c < '0' || c > '9') { break; } l += 1; low = +c + (low * 10); } high = low; if (c === ',') { l += 1; high = Infinity; c = s.charAt(l); if (c >= '0' && c <= '9') { l += 1; high = +c; for (;;) { c = s.charAt(l); if (c < '0' || c > '9') { break; } l += 1; high = +c + (high * 10); } } } if (s.charAt(l) !== '}') { warningAt("Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c); } else { l += 1; } if (s.charAt(l) === '?') { l += 1; } if (low > high) { warningAt("'{a}' should not be greater than '{b}'.", line, from + l, low, high); } } } } c = s.substr(0, l - 1); character += l; s = s.substr(l); return it('(regexp)', c); } return it('(punctuator)', t); // punctuator case '<!--': l = line; c = character; for (;;) { i = s.indexOf('--'); if (i >= 0) { break; } i = s.indexOf('<!'); if (i >= 0) { errorAt("Nested HTML comment.", line, character + i); } if (!nextLine()) { errorAt("Unclosed HTML comment.", l, c); } } l = s.indexOf('<!'); if (l >= 0 && l < i) { errorAt("Nested HTML comment.", line, character + l); } character += i; if (s[i + 2] !== '>') { errorAt("Expected -->.", line, character); } character += 3; s = s.slice(i + 3); break; case '#': if (xmode === 'html' || xmode === 'styleproperty') { for (;;) { c = s.charAt(0); if ((c < '0' || c > '9') && (c < 'a' || c > 'f') && (c < 'A' || c > 'F')) { break; } character += 1; s = s.substr(1); t += c; } if (t.length !== 4 && t.length !== 7) { warningAt("Bad hex color '{a}'.", line, from + l, t); } return it('(color)', t); } return it('(punctuator)', t); default: if (xmode === 'outer' && c === '&') { character += 1; s = s.substr(1); for (;;) { c = s.charAt(0); character += 1; s = s.substr(1); if (c === ';') { break; } if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || c === '#')) { errorAt("Bad entity", line, from + l, character); } } break; } return it('(punctuator)', t); } } } } }; }()); function addlabel(t, type) { if (option.safe && funct['(global)'] && typeof predefined[t] !== 'boolean') { warning('ADsafe global: ' + t + '.', token); } else if (t === 'hasOwnProperty') { warning("'hasOwnProperty' is a really bad name."); } // Define t in the current function in the current scope. if (is_own(funct, t) && !funct['(global)']) { warning(funct[t] === true ? "'{a}' was used before it was defined." : "'{a}' is already defined.", nexttoken, t); } funct[t] = type; if (funct['(global)']) { global[t] = funct; if (is_own(implied, t)) { warning("'{a}' was used before it was defined.", nexttoken, t); delete implied[t]; } } else { scope[t] = funct; } } function doOption() { var b, obj, filter, o = nexttoken.value, t, v; switch (o) { case '*/': error("Unbegun comment."); break; case '/*members': case '/*member': o = '/*members'; if (!membersOnly) { membersOnly = {}; } obj = membersOnly; break; case '/*jslint': if (option.safe) { warning("ADsafe restriction."); } obj = option; filter = boolOptions; break; case '/*global': if (option.safe) { warning("ADsafe restriction."); } obj = predefined; break; default: } t = lex.token(); loop: for (;;) { for (;;) { if (t.type === 'special' && t.value === '*/') { break loop; } if (t.id !== '(endline)' && t.id !== ',') { break; } t = lex.token(); } if (t.type !== '(string)' && t.type !== '(identifier)' && o !== '/*members') { error("Bad option.", t); } v = lex.token(); if (v.id === ':') { v = lex.token(); if (obj === membersOnly) { error("Expected '{a}' and instead saw '{b}'.", t, '*/', ':'); } if (t.value === 'indent' && o === '/*jslint') { b = +v.value; if (typeof b !== 'number' || !isFinite(b) || b <= 0 || Math.floor(b) !== b) { error("Expected a small integer and instead saw '{a}'.", v, v.value); } obj.white = true; obj.indent = b; } else if (t.value === 'maxerr' && o === '/*jslint') { b = +v.value; if (typeof b !== 'number' || !isFinite(b) || b <= 0 || Math.floor(b) !== b) { error("Expected a small integer and instead saw '{a}'.", v, v.value); } obj.maxerr = b; } else if (v.value === 'true') { obj[t.value] = true; } else if (v.value === 'false') { obj[t.value] = false; } else { error("Bad option value.", v); } t = lex.token(); } else { if (o === '/*jslint') { error("Missing option value.", t); } obj[t.value] = false; t = v; } } if (filter) { assume(); } } // We need a peek function. If it has an argument, it peeks that much farther // ahead. It is used to distinguish // for ( var i in ... // from // for ( var i = ... function peek(p) { var i = p || 0, j = 0, t; while (j <= i) { t = lookahead[j]; if (!t) { t = lookahead[j] = lex.token(); } j += 1; } return t; } // Produce the next token. It looks for programming errors. function advance(id, t) { switch (token.id) { case '(number)': if (nexttoken.id === '.') { warning( "A dot following a number can be confused with a decimal point.", token); } break; case '-': if (nexttoken.id === '-' || nexttoken.id === '--') { warning("Confusing minusses."); } break; case '+': if (nexttoken.id === '+' || nexttoken.id === '++') { warning("Confusing plusses."); } break; } if (token.type === '(string)' || token.identifier) { anonname = token.value; } if (id && nexttoken.id !== id) { if (t) { if (nexttoken.id === '(end)') { warning("Unmatched '{a}'.", t, t.id); } else { warning("Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.", nexttoken, id, t.id, t.line, nexttoken.value); } } else if (nexttoken.type !== '(identifier)' || nexttoken.value !== id) { warning("Expected '{a}' and instead saw '{b}'.", nexttoken, id, nexttoken.value); } } prevtoken = token; token = nexttoken; for (;;) { nexttoken = lookahead.shift() || lex.token(); if (nexttoken.id === '(end)' || nexttoken.id === '(error)') { return; } if (nexttoken.type === 'special') { doOption(); } else { if (nexttoken.id !== '(endline)') { break; } } } } // This is the heart of JSLINT, the Pratt parser. In addition to parsing, it // is looking for ad hoc lint patterns. We add to Pratt's model .fud, which is // like nud except that it is only used on the first token of a statement. // Having .fud makes it much easier to define JavaScript. I retained Pratt's // nomenclature. // .nud Null denotation // .fud First null denotation // .led Left denotation // lbp Left binding power // rbp Right binding power // They are key to the parsing method called Top Down Operator Precedence. function parse(rbp, initial) { var left; if (nexttoken.id === '(end)') { error("Unexpected early end of program.", token); } advance(); if (option.safe && typeof predefined[token.value] === 'boolean' && (nexttoken.id !== '(' && nexttoken.id !== '.')) { warning('ADsafe violation.', token); } if (initial) { anonname = 'anonymous'; funct['(verb)'] = token.value; } if (initial === true && token.fud) { left = token.fud(); } else { if (token.nud) { left = token.nud(); } else { if (nexttoken.type === '(number)' && token.id === '.') { warning( "A leading decimal point can be confused with a dot: '.{a}'.", token, nexttoken.value); advance(); return token; } else { error("Expected an identifier and instead saw '{a}'.", token, token.id); } } while (rbp < nexttoken.lbp) { advance(); if (token.led) { left = token.led(left); } else { error("Expected an operator and instead saw '{a}'.", token, token.id); } } } return left; } // Functions for conformance of style. function adjacent(left, right) { left = left || token; right = right || nexttoken; if (option.white || xmode === 'styleproperty' || xmode === 'style') { if (left.character !== right.from && left.line === right.line) { warning("Unexpected space after '{a}'.", right, left.value); } } } function nospace(left, right) { left = left || token; right = right || nexttoken; if (option.white && !left.comment) { if (left.line === right.line) { adjacent(left, right); } } } function nonadjacent(left, right) { if (option.white) { left = left || token; right = right || nexttoken; if (left.line === right.line && left.character === right.from) { warning("Missing space after '{a}'.", nexttoken, left.value); } } } function nobreaknonadjacent(left, right) { left = left || token; right = right || nexttoken; if (!option.laxbreak && left.line !== right.line) { warning("Bad line breaking before '{a}'.", right, right.id); } else if (option.white) { left = left || token; right = right || nexttoken; if (left.character === right.from) { warning("Missing space after '{a}'.", nexttoken, left.value); } } } function indentation(bias) { var i; if (option.white && nexttoken.id !== '(end)') { i = indent + (bias || 0); if (nexttoken.from !== i) { warning("Expected '{a}' to have an indentation at {b} instead at {c}.", nexttoken, nexttoken.value, i, nexttoken.from); } } } function nolinebreak(t) { t = t || token; if (t.line !== nexttoken.line) { warning("Line breaking error '{a}'.", t, t.value); } } function comma() { if (token.line !== nexttoken.line) { if (!option.laxbreak) { warning("Bad line breaking before '{a}'.", token, nexttoken.id); } } else if (token.character !== nexttoken.from && option.white) { warning("Unexpected space after '{a}'.", nexttoken, token.value); } advance(','); nonadjacent(token, nexttoken); } // Functional constructors for making the symbols that will be inherited by // tokens. function symbol(s, p) { var x = syntax[s]; if (!x || typeof x !== 'object') { syntax[s] = x = { id: s, lbp: p, value: s }; } return x; } function delim(s) { return symbol(s, 0); } function stmt(s, f) { var x = delim(s); x.identifier = x.reserved = true; x.fud = f; return x; } function blockstmt(s, f) { var x = stmt(s, f); x.block = true; return x; } function reserveName(x) { var c = x.id.charAt(0); if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) { x.identifier = x.reserved = true; } return x; } function prefix(s, f) { var x = symbol(s, 150); reserveName(x); x.nud = (typeof f === 'function') ? f : function () { this.right = parse(150); this.arity = 'unary'; if (this.id === '++' || this.id === '--') { if (option.plusplus) { warning("Unexpected use of '{a}'.", this, this.id); } else if ((!this.right.identifier || this.right.reserved) && this.right.id !== '.' && this.right.id !== '[') { warning("Bad operand.", this); } } return this; }; return x; } function type(s, f) { var x = delim(s); x.type = s; x.nud = f; return x; } function reserve(s, f) { var x = type(s, f); x.identifier = x.reserved = true; return x; } function reservevar(s, v) { return reserve(s, function () { if (this.id === 'this' || this.id === 'arguments') { if (strict_mode && funct['(global)']) { warning("Strict violation.", this); } else if (option.safe) { warning("ADsafe violation.", this); } } return this; }); } function infix(s, f, p, w) { var x = symbol(s, p); reserveName(x); x.led = function (left) { if (!w) { nobreaknonadjacent(prevtoken, token); nonadjacent(token, nexttoken); } if (typeof f === 'function') { return f(left, this); } else { this.left = left; this.right = parse(p); return this; } }; return x; } function relation(s, f) { var x = symbol(s, 100); x.led = function (left) { nobreaknonadjacent(prevtoken, token); nonadjacent(token, nexttoken); var right = parse(100); if ((left && left.id === 'NaN') || (right && right.id === 'NaN')) { warning("Use the isNaN function to compare with NaN.", this); } else if (f) { f.apply(this, [left, right]); } if (left.id === '!') { warning("Confusing use of '{a}'.", left, '!'); } if (right.id === '!') { warning("Confusing use of '{a}'.", left, '!'); } this.left = left; this.right = right; return this; }; return x; } function isPoorRelation(node) { return node && ((node.type === '(number)' && +node.value === 0) || (node.type === '(string)' && node.value === ' ') || node.type === 'true' || node.type === 'false' || node.type === 'undefined' || node.type === 'null'); } function assignop(s, f) { symbol(s, 20).exps = true; return infix(s, function (left, that) { var l; that.left = left; if (predefined[left.value] === false && scope[left.value]['(global)'] === true) { warning('Read only.', left); } if (option.safe) { l = left; do { if (typeof predefined[l.value] === 'boolean') { warning('ADsafe violation.', l); } l = l.left; } while (l); } if (left) { if (left.id === '.' || left.id === '[') { if (!left.left || left.left.value === 'arguments') { warning('Bad assignment.', that); } that.right = parse(19); return that; } else if (left.identifier && !left.reserved) { if (funct[left.value] === 'exception') { warning("Do not assign to the exception parameter.", left); } that.right = parse(19); return that; } if (left === syntax['function']) { warning( "Expected an identifier in an assignment and instead saw a function invocation.", token); } } error("Bad assignment.", that); }, 20); } function bitwise(s, f, p) { var x = symbol(s, p); reserveName(x); x.led = (typeof f === 'function') ? f : function (left) { if (option.bitwise) { warning("Unexpected use of '{a}'.", this, this.id); } this.left = left; this.right = parse(p); return this; }; return x; } function bitwiseassignop(s) { symbol(s, 20).exps = true; return infix(s, function (left, that) { if (option.bitwise) { warning("Unexpected use of '{a}'.", that, that.id); } nonadjacent(prevtoken, token); nonadjacent(token, nexttoken); if (left) { if (left.id === '.' || left.id === '[' || (left.identifier && !left.reserved)) { parse(19); return that; } if (left === syntax['function']) { warning( "Expected an identifier in an assignment, and instead saw a function invocation.", token); } return that; } error("Bad assignment.", that); }, 20); } function suffix(s, f) { var x = symbol(s, 150); x.led = function (left) { if (option.plusplus) { warning("Unexpected use of '{a}'.", this, this.id); } else if ((!left.identifier || left.reserved) && left.id !== '.' && left.id !== '[') { warning("Bad operand.", this); } this.left = left; return this; }; return x; } function optionalidentifier() { if (nexttoken.reserved) { warning("Expected an identifier and instead saw '{a}' (a reserved word).", nexttoken, nexttoken.id); } if (nexttoken.identifier) { advance(); return token.value; } } function identifier() { var i = optionalidentifier(); if (i) { return i; } if (token.id === 'function' && nexttoken.id === '(') { warning("Missing name in function statement."); } else { error("Expected an identifier and instead saw '{a}'.", nexttoken, nexttoken.value); } } function reachable(s) { var i = 0, t; if (nexttoken.id !== ';' || noreach) { return; } for (;;) { t = peek(i); if (t.reach) { return; } if (t.id !== '(endline)') { if (t.id === 'function') { warning( "Inner functions should be listed at the top of the outer function.", t); break; } warning("Unreachable '{a}' after '{b}'.", t, t.value, s); break; } i += 1; } } function statement(noindent) { var i = indent, r, s = scope, t = nexttoken; // We don't like the empty statement. if (t.id === ';') { warning("Unnecessary semicolon.", t); advance(';'); return; } // Is this a labelled statement? if (t.identifier && !t.reserved && peek().id === ':') { advance(); advance(':'); scope = Object.create(s); addlabel(t.value, 'label'); if (!nexttoken.labelled) { warning("Label '{a}' on {b} statement.", nexttoken, t.value, nexttoken.value); } if (jx.test(t.value + ':')) { warning("Label '{a}' looks like a javascript url.", t, t.value); } nexttoken.label = t.value; t = nexttoken; } // Parse the statement. if (!noindent) { indentation(); } if (nexttoken.id === 'new') { warning("'new' should not be used as a statement."); } r = parse(0, true); // Look for the final semicolon. if (!t.block) { if (!r || !r.exps) { warning( "Expected an assignment or function call and instead saw an expression.", token); } if (nexttoken.id !== ';') { warningAt("Missing semicolon.", token.line, token.from + token.value.length); } else { adjacent(token, nexttoken); advance(';'); nonadjacent(token, nexttoken); } } // Restore the indentation. indent = i; scope = s; return r; } function use_strict() { if (nexttoken.value === 'use strict') { advance(); advance(';'); strict_mode = true; return true; } else { return false; } } function statements(begin) { var a = [], f, p; if (begin && !use_strict() && option.strict) { warning('Missing "use strict" statement.', nexttoken); } if (option.adsafe) { switch (begin) { case 'script': if (!adsafe_may) { if (nexttoken.value !== 'ADSAFE' || peek(0).id !== '.' || (peek(1).value !== 'id' && peek(1).value !== 'go')) { error('ADsafe violation: Missing ADSAFE.id or ADSAFE.go.', nexttoken); } } if (nexttoken.value === 'ADSAFE' && peek(0).id === '.' && peek(1).value === 'id') { if (adsafe_may) { error('ADsafe violation.', nexttoken); } advance('ADSAFE'); advance('.'); advance('id'); advance('('); if (nexttoken.value !== adsafe_id) { error('ADsafe violation: id does not match.', nexttoken); } advance('(string)'); advance(')'); advance(';'); adsafe_may = true; } break; case 'lib': if (nexttoken.value === 'ADSAFE') { advance('ADSAFE'); advance('.'); advance('lib'); advance('('); advance('(string)'); comma(); f = parse(0); if (f.id !== 'function') { error('The second argument to lib must be a function.', f); } p = f.funct['(params)']; p = p && p.join(', '); if (p && p !== 'lib') { error("Expected '{a}' and instead saw '{b}'.", f, '(lib)', '(' + p + ')'); } advance(')'); advance(';'); return a; } else { error("ADsafe lib violation."); } } } while (!nexttoken.reach && nexttoken.id !== '(end)') { if (nexttoken.id === ';') { warning("Unnecessary semicolon."); advance(';'); } else { a.push(statement()); } } return a; } function block(f) { var a, b = inblock, old_indent = indent, s = scope, t; inblock = f; scope = Object.create(scope); nonadjacent(token, nexttoken); t = nexttoken; if (nexttoken.id === '{') { advance('{'); if (nexttoken.id !== '}' || token.line !== nexttoken.line) { indent += option.indent; while (!f && nexttoken.from > indent) { indent += option.indent; } if (!f) { use_strict(); } a = statements(); indent -= option.indent; indentation(); } advance('}', t); indent = old_indent; } else { warning("Expected '{a}' and instead saw '{b}'.", nexttoken, '{', nexttoken.value); noreach = true; a = [statement()]; noreach = false; } funct['(verb)'] = null; scope = s; inblock = b; return a; } // An identity function, used by string and number tokens. function idValue() { return this; } function countMember(m) { if (membersOnly && typeof membersOnly[m] !== 'boolean') { warning("Unexpected /*member '{a}'.", token, m); } if (typeof member[m] === 'number') { member[m] += 1; } else { member[m] = 1; } } function note_implied(token) { var name = token.value, line = token.line, a = implied[name]; if (typeof a === 'function') { a = false; } if (!a) { a = [line]; implied[name] = a; } else if (a[a.length - 1] !== line) { a.push(line); } } // CSS parsing. function cssName() { if (nexttoken.identifier) { advance(); return true; } } function cssNumber() { if (nexttoken.id === '-') { advance('-'); adjacent(); nolinebreak(); } if (nexttoken.type === '(number)') { advance('(number)'); return true; } } function cssString() { if (nexttoken.type === '(string)') { advance(); return true; } } function cssColor() { var i, number; if (nexttoken.identifier) { if (nexttoken.value === 'rgb') { advance(); advance('('); for (i = 0; i < 3; i += 1) { if (i) { advance(','); } number = nexttoken.value; if (nexttoken.type !== '(number)' || number < 0) { warning("Expected a positive number and instead saw '{a}'", nexttoken, number); advance(); } else { advance(); if (nexttoken.id === '%') { advance('%'); if (number > 100) { warning("Expected a percentage and instead saw '{a}'", token, number); } } else { if (number > 255) { warning("Expected a small number and instead saw '{a}'", token, number); } } } } advance(')'); return true; } else if (cssColorData[nexttoken.value] === true) { advance(); return true; } } else if (nexttoken.type === '(color)') { advance(); return true; } return false; } function cssLength() { if (nexttoken.id === '-') { advance('-'); adjacent(); nolinebreak(); } if (nexttoken.type === '(number)') { advance(); if (nexttoken.type !== '(string)' && cssLengthData[nexttoken.value] === true) { adjacent(); advance(); } else if (+token.value !== 0) { warning("Expected a linear unit and instead saw '{a}'.", nexttoken, nexttoken.value); } return true; } return false; } function cssLineHeight() { if (nexttoken.id === '-') { advance('-'); adjacent(); } if (nexttoken.type === '(number)') { advance(); if (nexttoken.type !== '(string)' && cssLengthData[nexttoken.value] === true) { adjacent(); advance(); } return true; } return false; } function cssWidth() { if (nexttoken.identifier) { switch (nexttoken.value) { case 'thin': case 'medium': case 'thick': advance(); return true; } } else { return cssLength(); } } function cssMargin() { if (nexttoken.identifier) { if (nexttoken.value === 'auto') { advance(); return true; } } else { return cssLength(); } } function cssAttr() { if (nexttoken.identifier && nexttoken.value === 'attr') { advance(); advance('('); if (!nexttoken.identifier) { warning("Expected a name and instead saw '{a}'.", nexttoken, nexttoken.value); } advance(); advance(')'); return true; } return false; } function cssCommaList() { while (nexttoken.id !== ';') { if (!cssName() && !cssString()) { warning("Expected a name and instead saw '{a}'.", nexttoken, nexttoken.value); } if (nexttoken.id !== ',') { return true; } comma(); } } function cssCounter() { if (nexttoken.identifier && nexttoken.value === 'counter') { advance(); advance('('); if (!nexttoken.identifier) { } advance(); if (nexttoken.id === ',') { comma(); if (nexttoken.type !== '(string)') { warning("Expected a string and instead saw '{a}'.", nexttoken, nexttoken.value); } advance(); } advance(')'); return true; } if (nexttoken.identifier && nexttoken.value === 'counters') { advance(); advance('('); if (!nexttoken.identifier) { warning("Expected a name and instead saw '{a}'.", nexttoken, nexttoken.value); } advance(); if (nexttoken.id === ',') { comma(); if (nexttoken.type !== '(string)') { warning("Expected a string and instead saw '{a}'.", nexttoken, nexttoken.value); } advance(); } if (nexttoken.id === ',') { comma(); if (nexttoken.type !== '(string)') { warning("Expected a string and instead saw '{a}'.", nexttoken, nexttoken.value); } advance(); } advance(')'); return true; } return false; } function cssShape() { var i; if (nexttoken.identifier && nexttoken.value === 'rect') { advance(); advance('('); for (i = 0; i < 4; i += 1) { if (!cssLength()) { warning("Expected a number and instead saw '{a}'.", nexttoken, nexttoken.value); break; } } advance(')'); return true; } return false; } function cssUrl() { var c, url; if (nexttoken.identifier && nexttoken.value === 'url') { nexttoken = lex.range('(', ')'); url = nexttoken.value; c = url.charAt(0); if (c === '"' || c === '\'') { if (url.slice(-1) !== c) { warning("Bad url string."); } else { url = url.slice(1, -1); if (url.indexOf(c) >= 0) { warning("Bad url string."); } } } if (!url) { warning("Missing url."); } advance(); if (option.safe && ux.test(url)) { error("ADsafe URL violation."); } urls.push(url); return true; } return false; } cssAny = [cssUrl, function () { for (;;) { if (nexttoken.identifier) { switch (nexttoken.value.toLowerCase()) { case 'url': cssUrl(); break; case 'expression': warning("Unexpected expression '{a}'.", nexttoken, nexttoken.value); advance(); break; default: advance(); } } else { if (nexttoken.id === ';' || nexttoken.id === '!' || nexttoken.id === '(end)' || nexttoken.id === '}') { return true; } advance(); } } }]; cssBorderStyle = [ 'none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'ridge', 'inset', 'outset' ]; cssBreak = [ 'auto', 'always', 'avoid', 'left', 'right' ]; cssOverflow = [ 'auto', 'hidden', 'scroll', 'visible' ]; cssAttributeData = { background: [ true, 'background-attachment', 'background-color', 'background-image', 'background-position', 'background-repeat' ], 'background-attachment': ['scroll', 'fixed'], 'background-color': ['transparent', cssColor], 'background-image': ['none', cssUrl], 'background-position': [ 2, [cssLength, 'top', 'bottom', 'left', 'right', 'center'] ], 'background-repeat': [ 'repeat', 'repeat-x', 'repeat-y', 'no-repeat' ], 'border': [true, 'border-color', 'border-style', 'border-width'], 'border-bottom': [ true, 'border-bottom-color', 'border-bottom-style', 'border-bottom-width' ], 'border-bottom-color': cssColor, 'border-bottom-style': cssBorderStyle, 'border-bottom-width': cssWidth, 'border-collapse': ['collapse', 'separate'], 'border-color': ['transparent', 4, cssColor], 'border-left': [ true, 'border-left-color', 'border-left-style', 'border-left-width' ], 'border-left-color': cssColor, 'border-left-style': cssBorderStyle, 'border-left-width': cssWidth, 'border-right': [ true, 'border-right-color', 'border-right-style', 'border-right-width' ], 'border-right-color': cssColor, 'border-right-style': cssBorderStyle, 'border-right-width': cssWidth, 'border-spacing': [2, cssLength], 'border-style': [4, cssBorderStyle], 'border-top': [ true, 'border-top-color', 'border-top-style', 'border-top-width' ], 'border-top-color': cssColor, 'border-top-style': cssBorderStyle, 'border-top-width': cssWidth, 'border-width': [4, cssWidth], bottom: [cssLength, 'auto'], 'caption-side' : ['bottom', 'left', 'right', 'top'], clear: ['both', 'left', 'none', 'right'], clip: [cssShape, 'auto'], color: cssColor, content: [ 'open-quote', 'close-quote', 'no-open-quote', 'no-close-quote', cssString, cssUrl, cssCounter, cssAttr ], 'counter-increment': [ cssName, 'none' ], 'counter-reset': [ cssName, 'none' ], cursor: [ cssUrl, 'auto', 'crosshair', 'default', 'e-resize', 'help', 'move', 'n-resize', 'ne-resize', 'nw-resize', 'pointer', 's-resize', 'se-resize', 'sw-resize', 'w-resize', 'text', 'wait' ], direction: ['ltr', 'rtl'], display: [ 'block', 'compact', 'inline', 'inline-block', 'inline-table', 'list-item', 'marker', 'none', 'run-in', 'table', 'table-caption', 'table-cell', 'table-column', 'table-column-group', 'table-footer-group', 'table-header-group', 'table-row', 'table-row-group' ], 'empty-cells': ['show', 'hide'], 'float': ['left', 'none', 'right'], font: [ 'caption', 'icon', 'menu', 'message-box', 'small-caption', 'status-bar', true, 'font-size', 'font-style', 'font-weight', 'font-family' ], 'font-family': cssCommaList, 'font-size': [ 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', 'larger', 'smaller', cssLength ], 'font-size-adjust': ['none', cssNumber], 'font-stretch': [ 'normal', 'wider', 'narrower', 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'semi-expanded', 'expanded', 'extra-expanded' ], 'font-style': [ 'normal', 'italic', 'oblique' ], 'font-variant': [ 'normal', 'small-caps' ], 'font-weight': [ 'normal', 'bold', 'bolder', 'lighter', cssNumber ], height: [cssLength, 'auto'], left: [cssLength, 'auto'], 'letter-spacing': ['normal', cssLength], 'line-height': ['normal', cssLineHeight], 'list-style': [ true, 'list-style-image', 'list-style-position', 'list-style-type' ], 'list-style-image': ['none', cssUrl], 'list-style-position': ['inside', 'outside'], 'list-style-type': [ 'circle', 'disc', 'square', 'decimal', 'decimal-leading-zero', 'lower-roman', 'upper-roman', 'lower-greek', 'lower-alpha', 'lower-latin', 'upper-alpha', 'upper-latin', 'hebrew', 'katakana', 'hiragana-iroha', 'katakana-oroha', 'none' ], margin: [4, cssMargin], 'margin-bottom': cssMargin, 'margin-left': cssMargin, 'margin-right': cssMargin, 'margin-top': cssMargin, 'marker-offset': [cssLength, 'auto'], 'max-height': [cssLength, 'none'], 'max-width': [cssLength, 'none'], 'min-height': cssLength, 'min-width': cssLength, opacity: cssNumber, outline: [true, 'outline-color', 'outline-style', 'outline-width'], 'outline-color': ['invert', cssColor], 'outline-style': [ 'dashed', 'dotted', 'double', 'groove', 'inset', 'none', 'outset', 'ridge', 'solid' ], 'outline-width': cssWidth, overflow: cssOverflow, 'overflow-x': cssOverflow, 'overflow-y': cssOverflow, padding: [4, cssLength], 'padding-bottom': cssLength, 'padding-left': cssLength, 'padding-right': cssLength, 'padding-top': cssLength, 'page-break-after': cssBreak, 'page-break-before': cssBreak, position: ['absolute', 'fixed', 'relative', 'static'], quotes: [8, cssString], right: [cssLength, 'auto'], 'table-layout': ['auto', 'fixed'], 'text-align': ['center', 'justify', 'left', 'right'], 'text-decoration': [ 'none', 'underline', 'overline', 'line-through', 'blink' ], 'text-indent': cssLength, 'text-shadow': ['none', 4, [cssColor, cssLength]], 'text-transform': ['capitalize', 'uppercase', 'lowercase', 'none'], top: [cssLength, 'auto'], 'unicode-bidi': ['normal', 'embed', 'bidi-override'], 'vertical-align': [ 'baseline', 'bottom', 'sub', 'super', 'top', 'text-top', 'middle', 'text-bottom', cssLength ], visibility: ['visible', 'hidden', 'collapse'], 'white-space': [ 'normal', 'nowrap', 'pre', 'pre-line', 'pre-wrap', 'inherit' ], width: [cssLength, 'auto'], 'word-spacing': ['normal', cssLength], 'word-wrap': ['break-word', 'normal'], 'z-index': ['auto', cssNumber] }; function styleAttribute() { var v; while (nexttoken.id === '*' || nexttoken.id === '#' || nexttoken.value === '_') { if (!option.css) { warning("Unexpected '{a}'.", nexttoken, nexttoken.value); } advance(); } if (nexttoken.id === '-') { if (!option.css) { warning("Unexpected '{a}'.", nexttoken, nexttoken.value); } advance('-'); if (!nexttoken.identifier) { warning( "Expected a non-standard style attribute and instead saw '{a}'.", nexttoken, nexttoken.value); } advance(); return cssAny; } else { if (!nexttoken.identifier) { warning("Excepted a style attribute, and instead saw '{a}'.", nexttoken, nexttoken.value); } else { if (is_own(cssAttributeData, nexttoken.value)) { v = cssAttributeData[nexttoken.value]; } else { v = cssAny; if (!option.css) { warning("Unrecognized style attribute '{a}'.", nexttoken, nexttoken.value); } } } advance(); return v; } } function styleValue(v) { var i = 0, n, once, match, round, start = 0, vi; switch (typeof v) { case 'function': return v(); case 'string': if (nexttoken.identifier && nexttoken.value === v) { advance(); return true; } return false; } for (;;) { if (i >= v.length) { return false; } vi = v[i]; i += 1; if (vi === true) { break; } else if (typeof vi === 'number') { n = vi; vi = v[i]; i += 1; } else { n = 1; } match = false; while (n > 0) { if (styleValue(vi)) { match = true; n -= 1; } else { break; } } if (match) { return true; } } start = i; once = []; for (;;) { round = false; for (i = start; i < v.length; i += 1) { if (!once[i]) { if (styleValue(cssAttributeData[v[i]])) { match = true; round = true; once[i] = true; break; } } } if (!round) { return match; } } } function styleChild() { if (nexttoken.id === '(number)') { advance(); if (nexttoken.value === 'n' && nexttoken.identifier) { adjacent(); advance(); if (nexttoken.id === '+') { adjacent(); advance('+'); adjacent(); advance('(number)'); } } return; } else { switch (nexttoken.value) { case 'odd': case 'even': if (nexttoken.identifier) { advance(); return; } } } warning("Unexpected token '{a}'.", nexttoken, nexttoken.value); } function substyle() { var v; for (;;) { if (nexttoken.id === '}' || nexttoken.id === '(end)' || xquote && nexttoken.id === xquote) { return; } while (nexttoken.id === ';') { warning("Misplaced ';'."); advance(';'); } v = styleAttribute(); advance(':'); if (nexttoken.identifier && nexttoken.value === 'inherit') { advance(); } else { if (!styleValue(v)) { warning("Unexpected token '{a}'.", nexttoken, nexttoken.value); advance(); } } if (nexttoken.id === '!') { advance('!'); adjacent(); if (nexttoken.identifier && nexttoken.value === 'important') { advance(); } else { warning("Expected '{a}' and instead saw '{b}'.", nexttoken, 'important', nexttoken.value); } } if (nexttoken.id === '}' || nexttoken.id === xquote) { warning("Missing '{a}'.", nexttoken, ';'); } else { advance(';'); } } } function styleSelector() { if (nexttoken.identifier) { if (!is_own(htmltag, nexttoken.value)) { warning("Expected a tagName, and instead saw {a}.", nexttoken, nexttoken.value); } advance(); } else { switch (nexttoken.id) { case '>': case '+': advance(); styleSelector(); break; case ':': advance(':'); switch (nexttoken.value) { case 'active': case 'after': case 'before': case 'checked': case 'disabled': case 'empty': case 'enabled': case 'first-child': case 'first-letter': case 'first-line': case 'first-of-type': case 'focus': case 'hover': case 'last-of-type': case 'link': case 'only-of-type': case 'root': case 'target': case 'visited': advance(); break; case 'lang': advance(); advance('('); if (!nexttoken.identifier) { warning("Expected a lang code, and instead saw :{a}.", nexttoken, nexttoken.value); } advance(')'); break; case 'nth-child': case 'nth-last-child': case 'nth-last-of-type': case 'nth-of-type': advance(); advance('('); styleChild(); advance(')'); break; case 'not': advance(); advance('('); if (nexttoken.id === ':' && peek(0).value === 'not') { warning("Nested not."); } styleSelector(); advance(')'); break; default: warning("Expected a pseudo, and instead saw :{a}.", nexttoken, nexttoken.value); } break; case '#': advance('#'); if (!nexttoken.identifier) { warning("Expected an id, and instead saw #{a}.", nexttoken, nexttoken.value); } advance(); break; case '*': advance('*'); break; case '.': advance('.'); if (!nexttoken.identifier) { warning("Expected a class, and instead saw #.{a}.", nexttoken, nexttoken.value); } advance(); break; case '[': advance('['); if (!nexttoken.identifier) { warning("Expected an attribute, and instead saw [{a}].", nexttoken, nexttoken.value); } advance(); if (nexttoken.id === '=' || nexttoken.value === '~=' || nexttoken.value === '$=' || nexttoken.value === '|=' || nexttoken.id === '*=' || nexttoken.id === '^=') { advance(); if (nexttoken.type !== '(string)') { warning("Expected a string, and instead saw {a}.", nexttoken, nexttoken.value); } advance(); } advance(']'); break; default: error("Expected a CSS selector, and instead saw {a}.", nexttoken, nexttoken.value); } } } function stylePattern() { var name; if (nexttoken.id === '{') { warning("Expected a style pattern, and instead saw '{a}'.", nexttoken, nexttoken.id); } else if (nexttoken.id === '@') { advance('@'); name = nexttoken.value; if (nexttoken.identifier && atrule[name] === true) { advance(); return name; } warning("Expected an at-rule, and instead saw @{a}.", nexttoken, name); } for (;;) { styleSelector(); if (nexttoken.id === '</' || nexttoken.id === '{' || nexttoken.id === '(end)') { return ''; } if (nexttoken.id === ',') { comma(); } } } function styles() { var i; while (nexttoken.id === '@') { i = peek(); if (i.identifier && i.value === 'import') { advance('@'); advance(); if (!cssUrl()) { warning("Expected '{a}' and instead saw '{b}'.", nexttoken, 'url', nexttoken.value); advance(); } advance(';'); } else { break; } } while (nexttoken.id !== '</' && nexttoken.id !== '(end)') { stylePattern(); xmode = 'styleproperty'; if (nexttoken.id === ';') { advance(';'); } else { advance('{'); substyle(); xmode = 'style'; advance('}'); } } } // HTML parsing. function doBegin(n) { if (n !== 'html' && !option.fragment) { if (n === 'div' && option.adsafe) { error("ADSAFE: Use the fragment option."); } else { error("Expected '{a}' and instead saw '{b}'.", token, 'html', n); } } if (option.adsafe) { if (n === 'html') { error( "Currently, ADsafe does not operate on whole HTML documents. It operates on <div> fragments and .js files.", token); } if (option.fragment) { if (n !== 'div') { error("ADsafe violation: Wrap the widget in a div.", token); } } else { error("Use the fragment option.", token); } } option.browser = true; assume(); } function doAttribute(n, a, v) { var u, x; if (a === 'id') { u = typeof v === 'string' ? v.toUpperCase() : ''; if (ids[u] === true) { warning("Duplicate id='{a}'.", nexttoken, v); } if (option.adsafe) { if (adsafe_id) { if (v.slice(0, adsafe_id.length) !== adsafe_id) { warning("ADsafe violation: An id must have a '{a}' prefix", nexttoken, adsafe_id); } else if (!/^[A-Z]+_[A-Z]+$/.test(v)) { warning("ADSAFE violation: bad id."); } } else { adsafe_id = v; if (!/^[A-Z]+_$/.test(v)) { warning("ADSAFE violation: bad id."); } } } x = v.search(dx); if (x >= 0) { warning("Unexpected character '{a}' in {b}.", token, v.charAt(x), a); } ids[u] = true; } else if (a === 'class' || a === 'type' || a === 'name') { x = v.search(qx); if (x >= 0) { warning("Unexpected character '{a}' in {b}.", token, v.charAt(x), a); } ids[u] = true; } else if (a === 'href' || a === 'background' || a === 'content' || a === 'data' || a.indexOf('src') >= 0 || a.indexOf('url') >= 0) { if (option.safe && ux.test(v)) { error("ADsafe URL violation."); } urls.push(v); } else if (a === 'for') { if (option.adsafe) { if (adsafe_id) { if (v.slice(0, adsafe_id.length) !== adsafe_id) { warning("ADsafe violation: An id must have a '{a}' prefix", nexttoken, adsafe_id); } else if (!/^[A-Z]+_[A-Z]+$/.test(v)) { warning("ADSAFE violation: bad id."); } } else { warning("ADSAFE violation: bad id."); } } } else if (a === 'name') { if (option.adsafe && v.indexOf('_') >= 0) { warning("ADsafe name violation."); } } } function doTag(n, a) { var i, t = htmltag[n], x; src = false; if (!t) { error("Unrecognized tag '<{a}>'.", nexttoken, n === n.toLowerCase() ? n : n + ' (capitalization error)'); } if (stack.length > 0) { if (n === 'html') { error("Too many <html> tags.", token); } x = t.parent; if (x) { if (x.indexOf(' ' + stack[stack.length - 1].name + ' ') < 0) { error("A '<{a}>' must be within '<{b}>'.", token, n, x); } } else if (!option.adsafe && !option.fragment) { i = stack.length; do { if (i <= 0) { error("A '<{a}>' must be within '<{b}>'.", token, n, 'body'); } i -= 1; } while (stack[i].name !== 'body'); } } switch (n) { case 'div': if (option.adsafe && stack.length === 1 && !adsafe_id) { warning("ADSAFE violation: missing ID_."); } break; case 'script': xmode = 'script'; advance('>'); indent = nexttoken.from; if (a.lang) { warning("lang is deprecated.", token); } if (option.adsafe && stack.length !== 1) { warning("ADsafe script placement violation.", token); } if (a.src) { if (option.adsafe && (!adsafe_may || !approved[a.src])) { warning("ADsafe unapproved script source.", token); } if (a.type) { warning("type is unnecessary.", token); } } else { if (adsafe_went) { error("ADsafe script violation.", token); } statements('script'); } xmode = 'html'; advance('</'); if (!nexttoken.identifier && nexttoken.value !== 'script') { warning("Expected '{a}' and instead saw '{b}'.", nexttoken, 'script', nexttoken.value); } advance(); xmode = 'outer'; break; case 'style': xmode = 'style'; advance('>'); styles(); xmode = 'html'; advance('</'); if (!nexttoken.identifier && nexttoken.value !== 'style') { warning("Expected '{a}' and instead saw '{b}'.", nexttoken, 'style', nexttoken.value); } advance(); xmode = 'outer'; break; case 'input': switch (a.type) { case 'radio': case 'checkbox': case 'button': case 'reset': case 'submit': break; case 'text': case 'file': case 'password': case 'file': case 'hidden': case 'image': if (option.adsafe && a.autocomplete !== 'off') { warning("ADsafe autocomplete violation."); } break; default: warning("Bad input type."); } break; case 'applet': case 'body': case 'embed': case 'frame': case 'frameset': case 'head': case 'iframe': case 'noembed': case 'noframes': case 'object': case 'param': if (option.adsafe) { warning("ADsafe violation: Disallowed tag: " + n); } break; } } function closetag(n) { return '</' + n + '>'; } function html() { var a, attributes, e, n, q, t, v, w = option.white, wmode; xmode = 'html'; xquote = ''; stack = null; for (;;) { switch (nexttoken.value) { case '<': xmode = 'html'; advance('<'); attributes = {}; t = nexttoken; if (!t.identifier) { warning("Bad identifier {a}.", t, t.value); } n = t.value; if (option.cap) { n = n.toLowerCase(); } t.name = n; advance(); if (!stack) { stack = []; doBegin(n); } v = htmltag[n]; if (typeof v !== 'object') { error("Unrecognized tag '<{a}>'.", t, n); } e = v.empty; t.type = n; for (;;) { if (nexttoken.id === '/') { advance('/'); if (nexttoken.id !== '>') { warning("Expected '{a}' and instead saw '{b}'.", nexttoken, '>', nexttoken.value); } break; } if (nexttoken.id && nexttoken.id.substr(0, 1) === '>') { break; } if (!nexttoken.identifier) { if (nexttoken.id === '(end)' || nexttoken.id === '(error)') { error("Missing '>'.", nexttoken); } warning("Bad identifier."); } option.white = true; nonadjacent(token, nexttoken); a = nexttoken.value; option.white = w; advance(); if (!option.cap && a !== a.toLowerCase()) { warning("Attribute '{a}' not all lower case.", nexttoken, a); } a = a.toLowerCase(); xquote = ''; if (is_own(attributes, a)) { warning("Attribute '{a}' repeated.", nexttoken, a); } if (a.slice(0, 2) === 'on') { if (!option.on) { warning("Avoid HTML event handlers."); } xmode = 'scriptstring'; advance('='); q = nexttoken.id; if (q !== '"' && q !== "'") { error("Missing quote."); } xquote = q; wmode = option.white; option.white = false; advance(q); statements('on'); option.white = wmode; if (nexttoken.id !== q) { error("Missing close quote on script attribute."); } xmode = 'html'; xquote = ''; advance(q); v = false; } else if (a === 'style') { xmode = 'scriptstring'; advance('='); q = nexttoken.id; if (q !== '"' && q !== "'") { error("Missing quote."); } xmode = 'styleproperty'; xquote = q; advance(q); substyle(); xmode = 'html'; xquote = ''; advance(q); v = false; } else { if (nexttoken.id === '=') { advance('='); v = nexttoken.value; if (!nexttoken.identifier && nexttoken.id !== '"' && nexttoken.id !== '\'' && nexttoken.type !== '(string)' && nexttoken.type !== '(number)' && nexttoken.type !== '(color)') { warning("Expected an attribute value and instead saw '{a}'.", token, a); } advance(); } else { v = true; } } attributes[a] = v; doAttribute(n, a, v); } doTag(n, attributes); if (!e) { stack.push(t); } xmode = 'outer'; advance('>'); break; case '</': xmode = 'html'; advance('</'); if (!nexttoken.identifier) { warning("Bad identifier."); } n = nexttoken.value; if (option.cap) { n = n.toLowerCase(); } advance(); if (!stack) { error("Unexpected '{a}'.", nexttoken, closetag(n)); } t = stack.pop(); if (!t) { error("Unexpected '{a}'.", nexttoken, closetag(n)); } if (t.name !== n) { error("Expected '{a}' and instead saw '{b}'.", nexttoken, closetag(t.name), closetag(n)); } if (nexttoken.id !== '>') { error("Missing '{a}'.", nexttoken, '>'); } xmode = 'outer'; advance('>'); break; case '<!': if (option.safe) { warning("ADsafe HTML violation."); } xmode = 'html'; for (;;) { advance(); if (nexttoken.id === '>' || nexttoken.id === '(end)') { break; } if (nexttoken.value.indexOf('--') >= 0) { warning("Unexpected --."); } if (nexttoken.value.indexOf('<') >= 0) { warning("Unexpected <."); } if (nexttoken.value.indexOf('>') >= 0) { warning("Unexpected >."); } } xmode = 'outer'; advance('>'); break; case '(end)': return; default: if (nexttoken.id === '(end)') { error("Missing '{a}'.", nexttoken, '</' + stack[stack.length - 1].value + '>'); } else { advance(); } } if (stack && stack.length === 0 && (option.adsafe || !option.fragment || nexttoken.id === '(end)')) { break; } } if (nexttoken.id !== '(end)') { error("Unexpected material after the end."); } } // Build the syntax table by declaring the syntactic elements of the language. type('(number)', idValue); type('(string)', idValue); syntax['(identifier)'] = { type: '(identifier)', lbp: 0, identifier: true, nud: function () { var v = this.value, s = scope[v], f; if (typeof s === 'function') { s = undefined; } else if (typeof s === 'boolean') { f = funct; funct = functions[0]; addlabel(v, 'var'); s = funct; funct = f; } // The name is in scope and defined in the current function. if (funct === s) { // Change 'unused' to 'var', and reject labels. switch (funct[v]) { case 'unused': funct[v] = 'var'; break; case 'label': warning("'{a}' is a statement label.", token, v); break; } // The name is not defined in the function. If we are in the global scope, // then we have an undefined variable. } else if (funct['(global)']) { if (option.undef && predefined[v] !== 'boolean') { warning("'{a}' is not defined.", token, v); } note_implied(token); // If the name is already defined in the current // function, but not as outer, then there is a scope error. } else { switch (funct[v]) { case 'closure': case 'function': case 'var': case 'unused': warning("'{a}' used out of scope.", token, v); break; case 'label': warning("'{a}' is a statement label.", token, v); break; case 'outer': case 'global': break; default: // If the name is defined in an outer function, make an outer entry, and if // it was unused, make it var. if (s === true) { funct[v] = true; } else if (s === null) { warning("'{a}' is not allowed.", token, v); note_implied(token); } else if (typeof s !== 'object') { if (option.undef) { warning("'{a}' is not defined.", token, v); } else { funct[v] = true; } note_implied(token); } else { switch (s[v]) { case 'function': case 'var': case 'unused': s[v] = 'closure'; funct[v] = s['(global)'] ? 'global' : 'outer'; break; case 'closure': case 'parameter': funct[v] = s['(global)'] ? 'global' : 'outer'; break; case 'label': warning("'{a}' is a statement label.", token, v); } } } } return this; }, led: function () { error("Expected an operator and instead saw '{a}'.", nexttoken, nexttoken.value); } }; type('(regexp)', function () { return this; }); delim('(endline)'); delim('(begin)'); delim('(end)').reach = true; delim('</').reach = true; delim('<!'); delim('<!--'); delim('-->'); delim('(error)').reach = true; delim('}').reach = true; delim(')'); delim(']'); delim('"').reach = true; delim("'").reach = true; delim(';'); delim(':').reach = true; delim(','); delim('#'); delim('@'); reserve('else'); reserve('case').reach = true; reserve('catch'); reserve('default').reach = true; reserve('finally'); reservevar('arguments'); reservevar('eval'); reservevar('false'); reservevar('Infinity'); reservevar('NaN'); reservevar('null'); reservevar('this'); reservevar('true'); reservevar('undefined'); assignop('=', 'assign', 20); assignop('+=', 'assignadd', 20); assignop('-=', 'assignsub', 20); assignop('*=', 'assignmult', 20); assignop('/=', 'assigndiv', 20).nud = function () { error("A regular expression literal can be confused with '/='."); }; assignop('%=', 'assignmod', 20); bitwiseassignop('&=', 'assignbitand', 20); bitwiseassignop('|=', 'assignbitor', 20); bitwiseassignop('^=', 'assignbitxor', 20); bitwiseassignop('<<=', 'assignshiftleft', 20); bitwiseassignop('>>=', 'assignshiftright', 20); bitwiseassignop('>>>=', 'assignshiftrightunsigned', 20); infix('?', function (left, that) { that.left = left; that.right = parse(10); advance(':'); that['else'] = parse(10); return that; }, 30); infix('||', 'or', 40); infix('&&', 'and', 50); bitwise('|', 'bitor', 70); bitwise('^', 'bitxor', 80); bitwise('&', 'bitand', 90); relation('==', function (left, right) { if (option.eqeqeq) { warning("Expected '{a}' and instead saw '{b}'.", this, '===', '=='); } else if (isPoorRelation(left)) { warning("Use '{a}' to compare with '{b}'.", this, '===', left.value); } else if (isPoorRelation(right)) { warning("Use '{a}' to compare with '{b}'.", this, '===', right.value); } return this; }); relation('==='); relation('!=', function (left, right) { if (option.eqeqeq) { warning("Expected '{a}' and instead saw '{b}'.", this, '!==', '!='); } else if (isPoorRelation(left)) { warning("Use '{a}' to compare with '{b}'.", this, '!==', left.value); } else if (isPoorRelation(right)) { warning("Use '{a}' to compare with '{b}'.", this, '!==', right.value); } return this; }); relation('!=='); relation('<'); relation('>'); relation('<='); relation('>='); bitwise('<<', 'shiftleft', 120); bitwise('>>', 'shiftright', 120); bitwise('>>>', 'shiftrightunsigned', 120); infix('in', 'in', 120); infix('instanceof', 'instanceof', 120); infix('+', function (left, that) { var right = parse(130); if (left && right && left.id === '(string)' && right.id === '(string)') { left.value += right.value; left.character = right.character; if (jx.test(left.value)) { warning("JavaScript URL.", left); } return left; } that.left = left; that.right = right; return that; }, 130); prefix('+', 'num'); infix('-', 'sub', 130); prefix('-', 'neg'); infix('*', 'mult', 140); infix('/', 'div', 140); infix('%', 'mod', 140); suffix('++', 'postinc'); prefix('++', 'preinc'); syntax['++'].exps = true; suffix('--', 'postdec'); prefix('--', 'predec'); syntax['--'].exps = true; prefix('delete', function () { var p = parse(0); if (!p || (p.id !== '.' && p.id !== '[')) { warning("Expected '{a}' and instead saw '{b}'.", nexttoken, '.', nexttoken.value); } this.first = p; return this; }).exps = true; prefix('~', function () { if (option.bitwise) { warning("Unexpected '{a}'.", this, '~'); } parse(150); return this; }); prefix('!', function () { this.right = parse(150); this.arity = 'unary'; if (bang[this.right.id] === true) { warning("Confusing use of '{a}'.", this, '!'); } return this; }); prefix('typeof', 'typeof'); prefix('new', function () { var c = parse(155), i; if (c && c.id !== 'function') { if (c.identifier) { c['new'] = true; switch (c.value) { case 'Object': warning("Use the object literal notation {}.", token); break; case 'Array': if (nexttoken.id !== '(') { warning("Use the array literal notation [].", token); } else { advance('('); if (nexttoken.id === ')') { warning("Use the array literal notation [].", token); } else { i = parse(0); c.dimension = i; if ((i.id === '(number)' && /[.+\-Ee]/.test(i.value)) || (i.id === '-' && !i.right) || i.id === '(string)' || i.id === '[' || i.id === '{' || i.id === 'true' || i.id === 'false' || i.id === 'null' || i.id === 'undefined' || i.id === 'Infinity') { warning("Use the array literal notation [].", token); } if (nexttoken.id !== ')') { error("Use the array literal notation [].", token); } } advance(')'); } this.first = c; return this; case 'Number': case 'String': case 'Boolean': case 'Math': case 'JSON': warning("Do not use {a} as a constructor.", token, c.value); break; case 'Function': if (!option.evil) { warning("The Function constructor is eval."); } break; case 'Date': case 'RegExp': break; default: if (c.id !== 'function') { i = c.value.substr(0, 1); if (option.newcap && (i < 'A' || i > 'Z')) { warning( "A constructor name should start with an uppercase letter.", token); } } } } else { if (c.id !== '.' && c.id !== '[' && c.id !== '(') { warning("Bad constructor.", token); } } } else { warning("Weird construction. Delete 'new'.", this); } adjacent(token, nexttoken); if (nexttoken.id !== '(') { warning("Missing '()' invoking a constructor."); } this.first = c; return this; }); syntax['new'].exps = true; infix('.', function (left, that) { adjacent(prevtoken, token); var m = identifier(); if (typeof m === 'string') { countMember(m); } that.left = left; that.right = m; if (!option.evil && left && left.value === 'document' && (m === 'write' || m === 'writeln')) { warning("document.write can be a form of eval.", left); } else if (option.adsafe) { if (left && left.value === 'ADSAFE') { if (m === 'id' || m === 'lib') { warning("ADsafe violation.", that); } else if (m === 'go') { if (xmode !== 'script') { warning("ADsafe violation.", that); } else if (adsafe_went || nexttoken.id !== '(' || peek(0).id !== '(string)' || peek(0).value !== adsafe_id || peek(1).id !== ',') { error("ADsafe violation: go.", that); } adsafe_went = true; adsafe_may = false; } } } if (!option.evil && (m === 'eval' || m === 'execScript')) { warning('eval is evil.'); } else if (option.safe) { for (;;) { if (banned[m] === true) { warning("ADsafe restricted word '{a}'.", token, m); } if (typeof predefined[left.value] !== 'boolean' || nexttoken.id === '(') { break; } if (standard_member[m] === true) { if (nexttoken.id === '.') { warning("ADsafe violation.", that); } break; } if (nexttoken.id !== '.') { warning("ADsafe violation.", that); break; } advance('.'); token.left = that; token.right = m; that = token; m = identifier(); if (typeof m === 'string') { countMember(m); } } } return that; }, 160, true); infix('(', function (left, that) { adjacent(prevtoken, token); nospace(); var n = 0, p = []; if (left) { if (left.type === '(identifier)') { if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) { if (left.value !== 'Number' && left.value !== 'String' && left.value !== 'Boolean' && left.value !== 'Date') { if (left.value === 'Math') { warning("Math is not a function.", left); } else if (option.newcap) { warning( "Missing 'new' prefix when invoking a constructor.", left); } } } } else if (left.id === '.') { if (option.safe && left.left.value === 'Math' && left.right === 'random') { warning("ADsafe violation.", left); } } } if (nexttoken.id !== ')') { for (;;) { p[p.length] = parse(10); n += 1; if (nexttoken.id !== ',') { break; } comma(); } } advance(')'); if (option.immed && left.id === 'function' && nexttoken.id !== ')') { warning("Wrap the entire immediate function invocation in parens.", that); } nospace(prevtoken, token); if (typeof left === 'object') { if (left.value === 'parseInt' && n === 1) { warning("Missing radix parameter.", left); } if (!option.evil) { if (left.value === 'eval' || left.value === 'Function' || left.value === 'execScript') { warning("eval is evil.", left); } else if (p[0] && p[0].id === '(string)' && (left.value === 'setTimeout' || left.value === 'setInterval')) { warning( "Implied eval is evil. Pass a function instead of a string.", left); } } if (!left.identifier && left.id !== '.' && left.id !== '[' && left.id !== '(' && left.id !== '&&' && left.id !== '||' && left.id !== '?') { warning("Bad invocation.", left); } } that.left = left; return that; }, 155, true).exps = true; prefix('(', function () { nospace(); var v = parse(0); advance(')', this); nospace(prevtoken, token); if (option.immed && v.id === 'function') { if (nexttoken.id === '(') { warning( "Move the invocation into the parens that contain the function.", nexttoken); } else { warning( "Do not wrap function literals in parens unless they are to be immediately invoked.", this); } } return v; }); infix('[', function (left, that) { nospace(); var e = parse(0), s; if (e && e.type === '(string)') { if (option.safe && banned[e.value] === true) { warning("ADsafe restricted word '{a}'.", that, e.value); } else if (!option.evil && (e.value === 'eval' || e.value === 'execScript')) { warning("eval is evil.", that); } else if (option.safe && (e.value.charAt(0) === '_' || e.value.charAt(0) === '-')) { warning("ADsafe restricted subscript '{a}'.", that, e.value); } countMember(e.value); if (!option.sub && ix.test(e.value)) { s = syntax[e.value]; if (!s || !s.reserved) { warning("['{a}'] is better written in dot notation.", e, e.value); } } } else if (!e || e.type !== '(number)' || e.value < 0) { if (option.safe) { warning('ADsafe subscripting.'); } } advance(']', that); nospace(prevtoken, token); that.left = left; that.right = e; return that; }, 160, true); prefix('[', function () { var b = token.line !== nexttoken.line; this.first = []; if (b) { indent += option.indent; if (nexttoken.from === indent + option.indent) { indent += option.indent; } } while (nexttoken.id !== '(end)') { while (nexttoken.id === ',') { warning("Extra comma."); advance(','); } if (nexttoken.id === ']') { break; } if (b && token.line !== nexttoken.line) { indentation(); } this.first.push(parse(10)); if (nexttoken.id === ',') { comma(); if (nexttoken.id === ']') { warning("Extra comma.", token); break; } } else { break; } } if (b) { indent -= option.indent; indentation(); } advance(']', this); return this; }, 160); (function (x) { x.nud = function () { var b, i, s, seen = {}; b = token.line !== nexttoken.line; if (b) { indent += option.indent; if (nexttoken.from === indent + option.indent) { indent += option.indent; } } for (;;) { if (nexttoken.id === '}') { break; } if (b) { indentation(); } i = optionalidentifier(true); if (!i) { if (nexttoken.id === '(string)') { i = nexttoken.value; if (ix.test(i)) { s = syntax[i]; } advance(); } else if (nexttoken.id === '(number)') { i = nexttoken.value.toString(); advance(); } else { error("Expected '{a}' and instead saw '{b}'.", nexttoken, '}', nexttoken.value); } } if (seen[i] === true) { warning("Duplicate member '{a}'.", nexttoken, i); } seen[i] = true; countMember(i); advance(':'); nonadjacent(token, nexttoken); parse(10); if (nexttoken.id === ',') { comma(); if (nexttoken.id === ',' || nexttoken.id === '}') { warning("Extra comma.", token); } } else { break; } } if (b) { indent -= option.indent; indentation(); } advance('}', this); return this; }; x.fud = function () { error("Expected to see a statement and instead saw a block.", token); }; }(delim('{'))); function varstatement(prefix) { // JavaScript does not have block scope. It only has function scope. So, // declaring a variable in a block can have unexpected consequences. var id, name, value; if (funct['(onevar)'] && option.onevar) { warning("Too many var statements."); } else if (!funct['(global)']) { funct['(onevar)'] = true; } this.first = []; for (;;) { nonadjacent(token, nexttoken); id = identifier(); if (funct['(global)'] && predefined[id] === false) { warning("Redefinition of '{a}'.", token, id); } addlabel(id, 'unused'); if (prefix) { break; } name = token; this.first.push(token); if (nexttoken.id === '=') { nonadjacent(token, nexttoken); advance('='); nonadjacent(token, nexttoken); if (peek(0).id === '=' && nexttoken.identifier) { error("Variable {a} was not declared correctly.", nexttoken, nexttoken.value); } value = parse(0); name.first = value; } if (nexttoken.id !== ',') { break; } comma(); } return this; } stmt('var', varstatement).exps = true; function functionparams() { var i, t = nexttoken, p = []; advance('('); nospace(); if (nexttoken.id === ')') { advance(')'); nospace(prevtoken, token); return; } for (;;) { i = identifier(); p.push(i); addlabel(i, 'parameter'); if (nexttoken.id === ',') { comma(); } else { advance(')', t); nospace(prevtoken, token); return p; } } } function doFunction(i) { var s = scope; scope = Object.create(s); funct = { '(name)' : i || '"' + anonname + '"', '(line)' : nexttoken.line, '(context)' : funct, '(breakage)': 0, '(loopage)' : 0, '(scope)' : scope }; token.funct = funct; functions.push(funct); if (i) { addlabel(i, 'function'); } funct['(params)'] = functionparams(); block(false); scope = s; funct['(last)'] = token.line; funct = funct['(context)']; } blockstmt('function', function () { if (inblock) { warning( "Function statements cannot be placed in blocks. Use a function expression or move the statement to the top of the outer function.", token); } var i = identifier(); adjacent(token, nexttoken); addlabel(i, 'unused'); doFunction(i); if (nexttoken.id === '(' && nexttoken.line === token.line) { error( "Function statements are not invocable. Wrap the whole function invocation in parens."); } return this; }); prefix('function', function () { var i = optionalidentifier(); if (i) { adjacent(token, nexttoken); } else { nonadjacent(token, nexttoken); } doFunction(i); if (funct['(loopage)'] && nexttoken.id !== '(') { warning("Be careful when making functions within a loop. Consider putting the function in a closure."); } return this; }); blockstmt('if', function () { var t = nexttoken; advance('('); nonadjacent(this, t); nospace(); parse(20); if (nexttoken.id === '=') { warning("Expected a conditional expression and instead saw an assignment."); advance('='); parse(20); } advance(')', t); nospace(prevtoken, token); block(true); if (nexttoken.id === 'else') { nonadjacent(token, nexttoken); advance('else'); if (nexttoken.id === 'if' || nexttoken.id === 'switch') { statement(true); } else { block(true); } } return this; }); blockstmt('try', function () { var b, e, s; if (option.adsafe) { warning("ADsafe try violation.", this); } block(false); if (nexttoken.id === 'catch') { advance('catch'); nonadjacent(token, nexttoken); advance('('); s = scope; scope = Object.create(s); e = nexttoken.value; if (nexttoken.type !== '(identifier)') { warning("Expected an identifier and instead saw '{a}'.", nexttoken, e); } else { addlabel(e, 'exception'); } advance(); advance(')'); block(false); b = true; scope = s; } if (nexttoken.id === 'finally') { advance('finally'); block(false); return; } else if (!b) { error("Expected '{a}' and instead saw '{b}'.", nexttoken, 'catch', nexttoken.value); } return this; }); blockstmt('while', function () { var t = nexttoken; funct['(breakage)'] += 1; funct['(loopage)'] += 1; advance('('); nonadjacent(this, t); nospace(); parse(20); if (nexttoken.id === '=') { warning("Expected a conditional expression and instead saw an assignment."); advance('='); parse(20); } advance(')', t); nospace(prevtoken, token); block(true); funct['(breakage)'] -= 1; funct['(loopage)'] -= 1; return this; }).labelled = true; reserve('with'); blockstmt('switch', function () { var t = nexttoken, g = false; funct['(breakage)'] += 1; advance('('); nonadjacent(this, t); nospace(); this.condition = parse(20); advance(')', t); nospace(prevtoken, token); nonadjacent(token, nexttoken); t = nexttoken; advance('{'); nonadjacent(token, nexttoken); indent += option.indent; this.cases = []; for (;;) { switch (nexttoken.id) { case 'case': switch (funct['(verb)']) { case 'break': case 'case': case 'continue': case 'return': case 'switch': case 'throw': break; default: warning( "Expected a 'break' statement before 'case'.", token); } indentation(-option.indent); advance('case'); this.cases.push(parse(20)); g = true; advance(':'); funct['(verb)'] = 'case'; break; case 'default': switch (funct['(verb)']) { case 'break': case 'continue': case 'return': case 'throw': break; default: warning( "Expected a 'break' statement before 'default'.", token); } indentation(-option.indent); advance('default'); g = true; advance(':'); break; case '}': indent -= option.indent; indentation(); advance('}', t); if (this.cases.length === 1 || this.condition.id === 'true' || this.condition.id === 'false') { warning("This 'switch' should be an 'if'.", this); } funct['(breakage)'] -= 1; funct['(verb)'] = undefined; return; case '(end)': error("Missing '{a}'.", nexttoken, '}'); return; default: if (g) { switch (token.id) { case ',': error("Each value should have its own case label."); return; case ':': statements(); break; default: error("Missing ':' on a case clause.", token); } } else { error("Expected '{a}' and instead saw '{b}'.", nexttoken, 'case', nexttoken.value); } } } }).labelled = true; stmt('debugger', function () { if (!option.debug) { warning("All 'debugger' statements should be removed."); } return this; }).exps = true; (function () { var x = stmt('do', function () { funct['(breakage)'] += 1; funct['(loopage)'] += 1; this.first = block(true); advance('while'); var t = nexttoken; nonadjacent(token, t); advance('('); nospace(); parse(20); if (nexttoken.id === '=') { warning("Expected a conditional expression and instead saw an assignment."); advance('='); parse(20); } advance(')', t); nospace(prevtoken, token); funct['(breakage)'] -= 1; funct['(loopage)'] -= 1; return this; }); x.labelled = true; x.exps = true; }()); blockstmt('for', function () { var f = option.forin, s, t = nexttoken; funct['(breakage)'] += 1; funct['(loopage)'] += 1; advance('('); nonadjacent(this, t); nospace(); if (peek(nexttoken.id === 'var' ? 1 : 0).id === 'in') { if (nexttoken.id === 'var') { advance('var'); varstatement(true); } else { switch (funct[nexttoken.value]) { case 'unused': funct[nexttoken.value] = 'var'; break; case 'var': break; default: warning("Bad for in variable '{a}'.", nexttoken, nexttoken.value); } advance(); } advance('in'); parse(20); advance(')', t); s = block(true); if (!f && (s.length > 1 || typeof s[0] !== 'object' || s[0].value !== 'if')) { warning("The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.", this); } funct['(breakage)'] -= 1; funct['(loopage)'] -= 1; return this; } else { if (nexttoken.id !== ';') { if (nexttoken.id === 'var') { advance('var'); varstatement(); } else { for (;;) { parse(0, 'for'); if (nexttoken.id !== ',') { break; } comma(); } } } nolinebreak(token); advance(';'); if (nexttoken.id !== ';') { parse(20); if (nexttoken.id === '=') { warning("Expected a conditional expression and instead saw an assignment."); advance('='); parse(20); } } nolinebreak(token); advance(';'); if (nexttoken.id === ';') { error("Expected '{a}' and instead saw '{b}'.", nexttoken, ')', ';'); } if (nexttoken.id !== ')') { for (;;) { parse(0, 'for'); if (nexttoken.id !== ',') { break; } comma(); } } advance(')', t); nospace(prevtoken, token); block(true); funct['(breakage)'] -= 1; funct['(loopage)'] -= 1; return this; } }).labelled = true; stmt('break', function () { var v = nexttoken.value; if (funct['(breakage)'] === 0) { warning("Unexpected '{a}'.", nexttoken, this.value); } nolinebreak(this); if (nexttoken.id !== ';') { if (token.line === nexttoken.line) { if (funct[v] !== 'label') { warning("'{a}' is not a statement label.", nexttoken, v); } else if (scope[v] !== funct) { warning("'{a}' is out of scope.", nexttoken, v); } this.first = nexttoken; advance(); } } reachable('break'); return this; }).exps = true; stmt('continue', function () { var v = nexttoken.value; if (funct['(breakage)'] === 0) { warning("Unexpected '{a}'.", nexttoken, this.value); } nolinebreak(this); if (nexttoken.id !== ';') { if (token.line === nexttoken.line) { if (funct[v] !== 'label') { warning("'{a}' is not a statement label.", nexttoken, v); } else if (scope[v] !== funct) { warning("'{a}' is out of scope.", nexttoken, v); } this.first = nexttoken; advance(); } } reachable('continue'); return this; }).exps = true; stmt('return', function () { nolinebreak(this); if (nexttoken.id === '(regexp)') { warning("Wrap the /regexp/ literal in parens to disambiguate the slash operator."); } if (nexttoken.id !== ';' && !nexttoken.reach) { nonadjacent(token, nexttoken); this.first = parse(20); } reachable('return'); return this; }).exps = true; stmt('throw', function () { nolinebreak(this); nonadjacent(token, nexttoken); this.first = parse(20); reachable('throw'); return this; }).exps = true; reserve('void'); // Superfluous reserved words reserve('class'); reserve('const'); reserve('enum'); reserve('export'); reserve('extends'); reserve('import'); reserve('super'); reserve('let'); reserve('yield'); reserve('implements'); reserve('interface'); reserve('package'); reserve('private'); reserve('protected'); reserve('public'); reserve('static'); function jsonValue() { function jsonObject() { var o = {}, t = nexttoken; advance('{'); if (nexttoken.id !== '}') { for (;;) { if (nexttoken.id === '(end)') { error("Missing '}' to match '{' from line {a}.", nexttoken, t.line); } else if (nexttoken.id === '}') { warning("Unexpected comma.", token); break; } else if (nexttoken.id === ',') { error("Unexpected comma.", nexttoken); } else if (nexttoken.id !== '(string)') { warning("Expected a string and instead saw {a}.", nexttoken, nexttoken.value); } if (o[nexttoken.value] === true) { warning("Duplicate key '{a}'.", nexttoken, nexttoken.value); } else if (nexttoken.value === '__proto__') { warning("Stupid key '{a}'.", nexttoken, nexttoken.value); } else { o[nexttoken.value] = true; } advance(); advance(':'); jsonValue(); if (nexttoken.id !== ',') { break; } advance(','); } } advance('}'); } function jsonArray() { var t = nexttoken; advance('['); if (nexttoken.id !== ']') { for (;;) { if (nexttoken.id === '(end)') { error("Missing ']' to match '[' from line {a}.", nexttoken, t.line); } else if (nexttoken.id === ']') { warning("Unexpected comma.", token); break; } else if (nexttoken.id === ',') { error("Unexpected comma.", nexttoken); } jsonValue(); if (nexttoken.id !== ',') { break; } advance(','); } } advance(']'); } switch (nexttoken.id) { case '{': jsonObject(); break; case '[': jsonArray(); break; case 'true': case 'false': case 'null': case '(number)': case '(string)': advance(); break; case '-': advance('-'); if (token.character !== nexttoken.from) { warning("Unexpected space after '-'.", token); } adjacent(token, nexttoken); advance('(number)'); break; default: error("Expected a JSON value.", nexttoken); } } // The actual JSLINT function itself. var itself = function (s, o) { var a, i; JSLINT.errors = []; predefined = Object.create(standard); if (o) { a = o.predef; if (a instanceof Array) { for (i = 0; i < a.length; i += 1) { predefined[a[i]] = true; } } if (o.adsafe) { o.safe = true; } if (o.safe) { o.browser = false; o.css = false; o.debug = false; o.eqeqeq = true; o.evil = false; o.forin = false; o.nomen = true; o.on = false; o.rhino = false; o.safe = true; o.sidebar = false; o.strict = true; o.sub = false; o.undef = true; o.widget = false; predefined.Date = null; predefined['eval'] = null; predefined.Function = null; predefined.Object = null; predefined.ADSAFE = false; predefined.lib = false; } option = o; } else { option = {}; } option.indent = option.indent || 4; option.maxerr = option.maxerr || 50; adsafe_id = ''; adsafe_may = false; adsafe_went = false; approved = {}; if (option.approved) { for (i = 0; i < option.approved.length; i += 1) { approved[option.approved[i]] = option.approved[i]; } } else { approved.test = 'test'; } tab = ''; for (i = 0; i < option.indent; i += 1) { tab += ' '; } indent = 1; global = Object.create(predefined); scope = global; funct = { '(global)': true, '(name)': '(global)', '(scope)': scope, '(breakage)': 0, '(loopage)': 0 }; functions = [funct]; ids = {}; urls = []; src = false; xmode = false; stack = null; member = {}; membersOnly = null; implied = {}; inblock = false; lookahead = []; jsonmode = false; warnings = 0; lex.init(s); prereg = true; strict_mode = false; prevtoken = token = nexttoken = syntax['(begin)']; assume(); try { advance(); if (nexttoken.value.charAt(0) === '<') { html(); if (option.adsafe && !adsafe_went) { warning("ADsafe violation: Missing ADSAFE.go.", this); } } else { switch (nexttoken.id) { case '{': case '[': option.laxbreak = true; jsonmode = true; jsonValue(); break; case '@': case '*': case '#': case '.': case ':': xmode = 'style'; advance(); if (token.id !== '@' || !nexttoken.identifier || nexttoken.value !== 'charset' || token.line !== 1 || token.from !== 1) { error('A css file should begin with @charset "UTF-8";'); } advance(); if (nexttoken.type !== '(string)' && nexttoken.value !== 'UTF-8') { error('A css file should begin with @charset "UTF-8";'); } advance(); advance(';'); styles(); break; default: if (option.adsafe && option.fragment) { error("Expected '{a}' and instead saw '{b}'.", nexttoken, '<div>', nexttoken.value); } statements('lib'); } } advance('(end)'); } catch (e) { if (e) { JSLINT.errors.push({ reason : e.message, line : e.line || nexttoken.line, character : e.character || nexttoken.from }, null); } } return JSLINT.errors.length === 0; }; function is_array(o) { return Object.prototype.toString.apply(o) === '[object Array]'; } function to_array(o) { var a = [], k; for (k in o) { if (is_own(o, k)) { a.push(k); } } return a; } // Data summary. itself.data = function () { var data = {functions: []}, fu, globals, implieds = [], f, i, j, members = [], n, unused = [], v; if (itself.errors.length) { data.errors = itself.errors; } if (jsonmode) { data.json = true; } for (n in implied) { if (is_own(implied, n)) { implieds.push({ name: n, line: implied[n] }); } } if (implieds.length > 0) { data.implieds = implieds; } if (urls.length > 0) { data.urls = urls; } globals = to_array(scope); if (globals.length > 0) { data.globals = globals; } for (i = 1; i < functions.length; i += 1) { f = functions[i]; fu = {}; for (j = 0; j < functionicity.length; j += 1) { fu[functionicity[j]] = []; } for (n in f) { if (is_own(f, n) && n.charAt(0) !== '(') { v = f[n]; if (is_array(fu[v])) { fu[v].push(n); if (v === 'unused') { unused.push({ name: n, line: f['(line)'], 'function': f['(name)'] }); } } } } for (j = 0; j < functionicity.length; j += 1) { if (fu[functionicity[j]].length === 0) { delete fu[functionicity[j]]; } } fu.name = f['(name)']; fu.param = f['(params)']; fu.line = f['(line)']; fu.last = f['(last)']; data.functions.push(fu); } if (unused.length > 0) { data.unused = unused; } members = []; for (n in member) { if (typeof member[n] === 'number') { data.member = member; break; } } return data; }; itself.report = function (option) { var data = itself.data(); var a = [], c, e, err, f, i, k, l, m = '', n, o = [], s; function detail(h, s) { if (s) { o.push('<div><i>' + h + '</i> ' + s.sort().join(', ') + '</div>'); } } if (data.errors || data.implieds || data.unused) { err = true; o.push('<div id=errors><i>Error:</i>'); if (data.errors) { for (i = 0; i < data.errors.length; i += 1) { c = data.errors[i]; if (c) { e = c.evidence || ''; o.push('<p>Problem' + (isFinite(c.line) ? ' at line ' + c.line + ' character ' + c.character : '') + ': ' + c.reason.entityify() + '</p><p class=evidence>' + (e && (e.length > 80 ? e.slice(0, 77) + '...' : e).entityify()) + '</p>'); } } } if (data.implieds) { s = []; for (i = 0; i < data.implieds.length; i += 1) { s[i] = '<code>' + data.implieds[i].name + '</code>&nbsp;<i>' + data.implieds[i].line + '</i>'; } o.push('<p><i>Implied global:</i> ' + s.join(', ') + '</p>'); } if (data.unused) { s = []; for (i = 0; i < data.unused.length; i += 1) { s[i] = '<code><u>' + data.unused[i].name + '</u></code>&nbsp;<i>' + data.unused[i].line + '</i> <code>' + data.unused[i]['function'] + '</code>'; } o.push('<p><i>Unused variable:</i> ' + s.join(', ') + '</p>'); } if (data.json) { o.push('<p>JSON: bad.</p>'); } o.push('</div>'); } if (!option) { o.push('<br><div id=functions>'); if (data.urls) { detail("URLs<br>", data.urls, '<br>'); } if (data.json && !err) { o.push('<p>JSON: good.</p>'); } else if (data.globals) { o.push('<div><i>Global</i> ' + data.globals.sort().join(', ') + '</div>'); } else { o.push('<div><i>No new global variables introduced.</i></div>'); } for (i = 0; i < data.functions.length; i += 1) { f = data.functions[i]; o.push('<br><div class=function><i>' + f.line + '-' + f.last + '</i> ' + (f.name || '') + '(' + (f.param ? f.param.join(', ') : '') + ')</div>'); detail('<big><b>Unused</b></big>', f.unused); detail('Closure', f.closure); detail('Variable', f['var']); detail('Exception', f.exception); detail('Outer', f.outer); detail('Global', f.global); detail('Label', f.label); } if (data.member) { a = to_array(data.member); if (a.length) { a = a.sort(); m = '<br><pre id=members>/*members '; l = 10; for (i = 0; i < a.length; i += 1) { k = a[i]; n = k.name(); if (l + n.length > 72) { o.push(m + '<br>'); m = ' '; l = 1; } l += n.length + 2; if (data.member[k] === 1) { n = '<i>' + n + '</i>'; } if (i < a.length - 1) { n += ', '; } m += n; } o.push(m + '<br>*/</pre>'); } o.push('</div>'); } } return o.join(''); }; itself.jslint = itself; itself.edition = '2009-10-04'; return itself; }()); Global.JSLINT = JSLINT })
/** ****************************************************************************************************************** * @file Describe what graph does. * @author Julian Jensen <[email protected]> * @since 1.0.0 * @date 19-Nov-2017 *********************************************************************************************************************/ "use strict"; const assert = require( 'assert' ); const EMBEDDED_INDEX = Symbol( 'embedded-index' ); /** * @template T * @this {Array<T>} */ class SparseCollection extends Array { /** */ constructor() { super(); this.ifNotObject = new Map(); this.index = 0; /** @type {Array<number>} */ this.unused = []; } /** * @param {T} value * @return {T} */ add( value ) { const index = this.unused.length ? this.unused.pop() : this.length; assert( !this[ index ] ); assert( typeof value === 'object' && value !== null && !Array.isArray( value ) ); Object.defineProperty( value, EMBEDDED_INDEX, { enumerable: false, value: index } ); this[ index ] = value; return value; } /** * @param {T|function():T} value * @param {*[]} params * @return {T} */ addNew( value, ...params ) { return this.add( typeof value === 'function' ? value( ...params ) : value ); } /** * @param {T} value */ remove( value ) { assert( Reflect.has( value, EMBEDDED_INDEX ) ); this.unused.push( value[ EMBEDDED_INDEX ] ); this[ value[ EMBEDDED_INDEX ] ] = void 0; } /** */ packIndices() { if ( !this.unused.length ) return; let holeIndex = 0, endIndex = this.length; while ( true ) { while ( holeIndex < endIndex && this[ holeIndex ] ) ++holeIndex; if ( holeIndex === endIndex ) break; assert( holeIndex < this.length ); assert( !this[ holeIndex ] ); do --endIndex; while ( !this[ endIndex ] && endIndex > holeIndex ); if ( holeIndex === endIndex ) break; assert( endIndex > holeIndex ); assert( this[ endIndex ] ); const value = this[ endIndex ]; value[ EMBEDDED_INDEX ] = holeIndex; this[ holeIndex ] = value; ++holeIndex; } this.unused = []; this.length = endIndex; } /** * @return {number} */ size() { return this.length; } /** * @return {boolean} */ isEmpty() { return !this.length; } /** * @param {number} index * @return {T} */ at( index ) { return this[ index ]; } } /** */ export class Graph { /** */ constructor() { this.slotVisitor = null; this.nodes = new SparseCollection(); this.blocks = []; this.roots = []; } /** * @param params */ addNode( ...params ) { this.nodes.addNew( ...params ); } /** * @return {number} */ maxNodeCount() { return this.nodes.size(); } /** * @param index * @return {T} */ nodeAt( index ) { return this.nodes[ index ]; } }
/* nagenawa.js */ ui.debug.addDebugData("nagenawa", { url: "6/6/alrrlafbaaqu3011314g223h", failcheck: [ [ "brNoLine", "pzprv3/nagenawa/6/6/13/0 0 1 1 2 2 /0 3 3 4 4 2 /5 3 6 6 4 7 /5 8 6 6 9 7 /10 8 8 9 9 11 /10 10 12 12 11 11 /3 . 0 . 1 . /. 1 . 3 . . /1 . 4 . . . /. 2 . . . . /3 . . 2 . . /. . . . . . /0 0 0 0 0 /0 0 0 0 0 /0 0 0 0 0 /0 0 0 0 0 /0 0 0 0 0 /0 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /" ], [ "bkLineGt", "pzprv3/nagenawa/6/6/13/0 0 1 1 2 2 /0 3 3 4 4 2 /5 3 6 6 4 7 /5 8 6 6 9 7 /10 8 8 9 9 11 /10 10 12 12 11 11 /3 . 0 . 1 . /. 1 . 3 . . /1 . 4 . . . /. 2 . . . . /3 . . 2 . . /. . . . . . /1 0 0 0 0 /0 0 0 0 0 /1 0 0 0 0 /0 0 0 0 0 /0 0 0 0 0 /0 0 0 0 0 /1 1 0 0 0 0 /1 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 2 2 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /" ], [ "lnBranch", "pzprv3/nagenawa/6/6/13/0 0 1 1 2 2 /0 3 3 4 4 2 /5 3 6 6 4 7 /5 8 6 6 9 7 /10 8 8 9 9 11 /10 10 12 12 11 11 /3 . 0 . 1 . /. 1 . 3 . . /1 . 4 . . . /. 2 . . . . /3 . . 2 . . /. . . . . . /1 0 0 0 0 /1 0 0 0 0 /0 0 0 0 0 /1 0 0 0 0 /1 0 0 0 0 /1 0 0 0 0 /1 1 0 0 0 0 /0 0 0 0 0 0 /0 0 0 0 0 0 /1 0 0 0 0 0 /1 0 0 0 0 0 /0 0 2 2 0 0 /0 0 2 0 0 0 /2 2 0 0 0 0 /1 0 0 0 0 0 /1 0 0 0 0 0 /1 1 0 0 0 0 /" ], [ "lnDeadEnd", "pzprv3/nagenawa/6/6/13/0 0 1 1 2 2 /0 3 3 4 4 2 /5 3 6 6 4 7 /5 8 6 6 9 7 /10 8 8 9 9 11 /10 10 12 12 11 11 /3 . 0 . 1 . /. 1 . 3 . . /1 . 4 . . . /. 2 . . . . /3 . . 2 . . /. . . . . . /1 0 0 0 0 /1 0 0 1 0 /0 0 1 1 0 /1 0 0 0 0 /0 0 0 0 0 /1 0 0 0 0 /1 1 0 0 0 0 /0 0 0 1 0 0 /0 0 1 1 0 0 /1 1 0 0 0 0 /1 1 0 0 0 0 /0 0 2 2 0 0 /0 0 2 0 0 0 /2 2 0 0 0 0 /1 0 0 0 0 0 /1 0 2 0 0 0 /1 1 0 0 0 0 /" ], [ "bkLineLt", "pzprv3/nagenawa/6/6/13/0 0 1 1 2 2 /0 3 3 4 4 2 /5 3 6 6 4 7 /5 8 6 6 9 7 /10 8 8 9 9 11 /10 10 12 12 11 11 /3 . 0 . 1 . /. 1 . 3 . . /1 . 4 . . . /. 2 . . . . /3 . . 2 . . /. . . . . . /1 0 0 0 0 /1 0 0 1 0 /0 0 1 1 0 /1 0 1 0 0 /0 0 0 0 0 /1 0 0 0 0 /1 1 0 0 0 0 /0 0 0 1 1 0 /0 0 1 1 0 0 /1 1 0 0 0 0 /1 1 0 0 0 0 /0 0 2 2 0 0 /0 0 2 0 0 0 /2 2 0 0 0 0 /1 0 0 0 0 0 /1 0 2 0 0 0 /1 1 0 0 0 0 /" ], [ "lnNotRect", "pzprv3/nagenawa/6/6/13/0 0 1 1 2 2 /0 3 3 4 4 2 /5 3 6 6 4 7 /5 8 6 6 9 7 /10 8 8 9 9 11 /10 10 12 12 11 11 /3 . 0 . 1 . /. 1 . 3 . . /1 . 4 . . . /. . . . . . /3 . . 2 . . /. . . . . . /1 0 0 0 0 /1 0 0 1 1 /0 0 1 1 0 /1 0 1 1 0 /0 0 1 0 0 /1 0 1 1 1 /1 1 0 0 0 0 /0 0 0 1 0 1 /0 0 1 1 1 1 /1 1 0 1 0 1 /1 1 1 0 0 1 /0 0 2 2 0 0 /0 0 2 0 0 0 /2 2 0 0 0 0 /1 0 0 0 0 0 /1 0 2 0 0 0 /1 1 0 0 0 0 /" ], [ null, "pzprv3/nagenawa/6/6/13/0 0 1 1 2 2 /0 3 3 4 4 2 /5 3 6 6 4 7 /5 8 6 6 9 7 /10 8 8 9 9 11 /10 10 12 12 11 11 /3 . 0 . 1 . /. 1 . 3 . . /1 . 4 . . . /. 2 . . . . /3 . . 2 . . /. . . . . . /1 0 0 0 0 /1 0 0 1 1 /0 0 1 1 0 /1 0 1 1 0 /0 0 0 0 0 /1 0 0 1 1 /1 1 0 0 0 0 /0 0 0 1 0 1 /0 0 1 1 1 1 /1 1 0 1 0 1 /1 1 0 1 0 1 /0 0 2 2 0 0 /0 0 2 0 0 0 /2 2 0 0 0 0 /1 0 0 0 0 0 /1 0 2 0 0 0 /1 1 0 0 0 0 /" ] ], inputs: [ /* 回答入力はicebarn, countryと同じなので省略 */ /* 問題入力はcountryと同じなので省略 */ ] });
/* Rather than manage one giant configuration file responsible for creating multiple gulp tasks, each task has been broken out into its own file. Any files in that directory get automatically required below. To add a new task, simply add a new task file that directory. gulp/tasks/default.js specifies the default set of tasks to run when you run `gulp`. Principle taken from gulp-starter: https://github.com/greypants/gulp-starter */ "use strict"; import requireDir from "require-dir"; import utils from "./gulp/utils"; /** * This class takes care of loading gulp tasks. */ class TasksLoader { constructor(){ } /** * Looks for and registers all available tasks. * @param inputGulp the gulp object to use. If not provided, it'll be loaded * @param inputOptions the build options to use. If not provided, an empty object is used */ registerTasks(inputGulp, inputOptions){ let gulp = inputGulp || require("gulp"); // this module can be imported without a defined gulp instance let options = inputOptions || {}; gulp = utils.configureGulpObject(gulp, options); // we need to customize the gulp object a bit // Load all tasks in gulp/tasks const loadedModules = requireDir("./gulp/tasks", { recurse: false }); // request each module to register its tasks for(let key in loadedModules){ if(loadedModules.hasOwnProperty(key)){ let loadedModule = loadedModules[ key ]; if(loadedModule.registerTask){ //console.log(`Registering module: ${key}`); loadedModule.registerTask(gulp); } else{ throw new TypeError(`The following module does not expose the expected interface: ${key}`); } } } } } export default new TasksLoader();
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class LocalNetworkGatewaysOperations(object): """LocalNetworkGatewaysOperations operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. :type models: ~azure.mgmt.network.v2018_12_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. """ models = _models def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer self._config = config def _create_or_update_initial( self, resource_group_name, # type: str local_network_gateway_name, # type: str parameters, # type: "_models.LocalNetworkGateway" **kwargs # type: Any ): # type: (...) -> "_models.LocalNetworkGateway" cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalNetworkGateway"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) api_version = "2018-12-01" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL url = self._create_or_update_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'localNetworkGatewayName': self._serialize.url("local_network_gateway_name", local_network_gateway_name, 'str', min_length=1), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'LocalNetworkGateway') body_content_kwargs['content'] = body_content request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('LocalNetworkGateway', pipeline_response) if response.status_code == 201: deserialized = self._deserialize('LocalNetworkGateway', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}'} # type: ignore def begin_create_or_update( self, resource_group_name, # type: str local_network_gateway_name, # type: str parameters, # type: "_models.LocalNetworkGateway" **kwargs # type: Any ): # type: (...) -> LROPoller["_models.LocalNetworkGateway"] """Creates or updates a local network gateway in the specified resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param local_network_gateway_name: The name of the local network gateway. :type local_network_gateway_name: str :param parameters: Parameters supplied to the create or update local network gateway operation. :type parameters: ~azure.mgmt.network.v2018_12_01.models.LocalNetworkGateway :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either LocalNetworkGateway or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.network.v2018_12_01.models.LocalNetworkGateway] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalNetworkGateway"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, local_network_gateway_name=local_network_gateway_name, parameters=parameters, cls=lambda x,y,z: x, **kwargs ) kwargs.pop('error_map', None) kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('LocalNetworkGateway', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'localNetworkGatewayName': self._serialize.url("local_network_gateway_name", local_network_gateway_name, 'str', min_length=1), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}'} # type: ignore def get( self, resource_group_name, # type: str local_network_gateway_name, # type: str **kwargs # type: Any ): # type: (...) -> "_models.LocalNetworkGateway" """Gets the specified local network gateway in a resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param local_network_gateway_name: The name of the local network gateway. :type local_network_gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LocalNetworkGateway, or the result of cls(response) :rtype: ~azure.mgmt.network.v2018_12_01.models.LocalNetworkGateway :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalNetworkGateway"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) api_version = "2018-12-01" accept = "application/json" # Construct URL url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'localNetworkGatewayName': self._serialize.url("local_network_gateway_name", local_network_gateway_name, 'str', min_length=1), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize('LocalNetworkGateway', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}'} # type: ignore def _delete_initial( self, resource_group_name, # type: str local_network_gateway_name, # type: str **kwargs # type: Any ): # type: (...) -> None cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) api_version = "2018-12-01" # Construct URL url = self._delete_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'localNetworkGatewayName': self._serialize.url("local_network_gateway_name", local_network_gateway_name, 'str', min_length=1), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} # type: Dict[str, Any] request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}'} # type: ignore def begin_delete( self, resource_group_name, # type: str local_network_gateway_name, # type: str **kwargs # type: Any ): # type: (...) -> LROPoller[None] """Deletes the specified local network gateway. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param local_network_gateway_name: The name of the local network gateway. :type local_network_gateway_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, local_network_gateway_name=local_network_gateway_name, cls=lambda x,y,z: x, **kwargs ) kwargs.pop('error_map', None) kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'localNetworkGatewayName': self._serialize.url("local_network_gateway_name", local_network_gateway_name, 'str', min_length=1), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}'} # type: ignore def _update_tags_initial( self, resource_group_name, # type: str local_network_gateway_name, # type: str parameters, # type: "_models.TagsObject" **kwargs # type: Any ): # type: (...) -> "_models.LocalNetworkGateway" cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalNetworkGateway"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) api_version = "2018-12-01" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL url = self._update_tags_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'localNetworkGatewayName': self._serialize.url("local_network_gateway_name", local_network_gateway_name, 'str', min_length=1), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'TagsObject') body_content_kwargs['content'] = body_content request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize('LocalNetworkGateway', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized _update_tags_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}'} # type: ignore def begin_update_tags( self, resource_group_name, # type: str local_network_gateway_name, # type: str parameters, # type: "_models.TagsObject" **kwargs # type: Any ): # type: (...) -> LROPoller["_models.LocalNetworkGateway"] """Updates a local network gateway tags. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param local_network_gateway_name: The name of the local network gateway. :type local_network_gateway_name: str :param parameters: Parameters supplied to update local network gateway tags. :type parameters: ~azure.mgmt.network.v2018_12_01.models.TagsObject :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either LocalNetworkGateway or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.network.v2018_12_01.models.LocalNetworkGateway] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalNetworkGateway"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: raw_result = self._update_tags_initial( resource_group_name=resource_group_name, local_network_gateway_name=local_network_gateway_name, parameters=parameters, cls=lambda x,y,z: x, **kwargs ) kwargs.pop('error_map', None) kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('LocalNetworkGateway', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'localNetworkGatewayName': self._serialize.url("local_network_gateway_name", local_network_gateway_name, 'str', min_length=1), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}'} # type: ignore def list( self, resource_group_name, # type: str **kwargs # type: Any ): # type: (...) -> Iterable["_models.LocalNetworkGatewayListResult"] """Gets all the local network gateways in a resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LocalNetworkGatewayListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.network.v2018_12_01.models.LocalNetworkGatewayListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalNetworkGatewayListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) api_version = "2018-12-01" accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL url = self.list.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') request = self._client.get(url, query_parameters, header_parameters) else: url = next_link query_parameters = {} # type: Dict[str, Any] request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): deserialized = self._deserialize('LocalNetworkGatewayListResult', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways'} # type: ignore
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var React = _interopRequireWildcard(require("react")); var _createSvgIcon = _interopRequireDefault(require("./utils/createSvgIcon")); var _default = (0, _createSvgIcon["default"])( /*#__PURE__*/React.createElement("path", { d: "M21 8V7l-3 2-3-2v1l3 2 3-2zm1-5H2C.9 3 0 3.9 0 5v14c0 1.1.9 2 2 2h20c1.1 0 1.99-.9 1.99-2L24 5c0-1.1-.9-2-2-2zM8 6c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm6 12H2v-1c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1zm8-6h-8V6h8v6z" }), 'ContactMail'); exports["default"] = _default;
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # PennyLane documentation build configuration file, created by # sphinx-quickstart on Tue Apr 17 11:43:51 2018. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os, re # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath('..')) sys.path.insert(0, os.path.abspath('_ext')) sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath('.')), 'doc')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. needs_sphinx = '1.6' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.mathjax', 'sphinx.ext.napoleon', 'sphinx.ext.inheritance_diagram', 'sphinx.ext.viewcode', 'sphinxcontrib.bibtex', 'edit_on_github', 'sphinx.ext.graphviz', # 'sphinx_gallery.gen_gallery', "sphinx.ext.intersphinx", "sphinx_automodapi.automodapi", 'sphinx_copybutton', "m2r" ] source_suffix = ['.rst', '.md'] autosummary_generate = True autosummary_imported_members = False automodapi_toctreedirnm = "code/api" automodsumm_inherited_members = True intersphinx_mapping = {"https://pennylane.ai/qml/": None} mathjax_path = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" from glob import glob import shutil import os import warnings # sphinx_gallery_conf = { # # path to your example scripts # 'examples_dirs': '../examples', # # path where to save gallery generated examples # 'gallery_dirs': 'tutorials', # # build files that start 'pennylane_run' # 'filename_pattern': r'pennylane_run', # # first notebook cell in generated Jupyter notebooks # 'first_notebook_cell': "%matplotlib inline", # # thumbnail size # 'thumbnail_size': (400, 400), # } # Remove warnings that occur when generating the the tutorials warnings.filterwarnings("ignore", category=UserWarning, message=r"Matplotlib is currently using agg") warnings.filterwarnings("ignore", category=FutureWarning, message=r"Passing \(type, 1\) or '1type' as a synonym of type is deprecated.+") warnings.filterwarnings("ignore", category=UserWarning, message=r".+?Compilation using quilc will not be available\.") # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates', 'xanadu_theme'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General information about the project. project = 'PennyLane' copyright = """\ Ville Bergholm, Josh Izaac, Maria Schuld, Christian Gogolin, M. Sohaib Alam, Shahnawaz Ahmed, Juan Miguel Arrazola, Carsten Blank, Alain Delgado, Soran Jahangiri, Keri McKiernan, Johannes Jakob Meyer, Zeyue Niu, Antal Száva, and Nathan Killoran. <br> PennyLane: Automatic differentiation of hybrid quantum-classical computations. arXiv:1811.04968, 2018.<br> &copy; Copyright 2018-2020, Xanadu Quantum Technologies Inc.""" author = 'Xanadu Inc.' add_module_names = False # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. import pennylane try: import pennylane_qchem except ImportError: from unittest.mock import MagicMock class Mock(MagicMock): __name__ = 'foo' __repr__ = lambda self: __name__ @classmethod def __getattr__(cls, name): return MagicMock() MOCK_MODULES = [ 'pennylane_qchem', 'pennylane_qchem.qchem', ] mock_fn = Mock(__name__='foo') mock_fns = {"__all__": list(), "__dir__": list(), "__dict__": dict()} mock = Mock(**mock_fns) for mod_name in MOCK_MODULES: sys.modules[mod_name] = mock # The full version, including alpha/beta/rc tags. release = pennylane.__version__ # The short X.Y version. version = re.match(r'^(\d+\.\d+)', release).expand(r'\1') # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # today_fmt is used as the format for a strftime call. today_fmt = '%Y-%m-%d' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. show_authors = True # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = 'nature' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (relative to this directory) to use as a favicon of # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. html_favicon = '_static/favicon.ico' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. #html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, must be a dictionary that maps document names # to template names. # # This is required for the alabaster theme # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars #html_sidebars = { # '**': [ # 'about.html', # 'navigation.html', # 'relations.html', # needs 'show_related': True theme option to display # 'searchbox.html', # 'donate.html', # ] #} html_sidebars = { '**' : [ 'logo-text.html', 'searchbox.html', 'globaltoc.html', # 'sourcelink.html' ] } # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g., ".xhtml"). #html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr' #html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # Now only 'ja' uses this config value #html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. #html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. htmlhelp_basename = 'PennyLanedoc' # # -- Xanadu theme --------------------------------------------------------- html_theme = 'xanadu_theme' html_theme_path = ['.'] # Register the theme as an extension to generate a sitemap.xml # extensions.append("guzzle_sphinx_theme") # xanadu theme options (see theme.conf for more information) html_theme_options = { # Set the path to a special layout to include for the homepage # "index_template": "special_index.html", # Set the name of the project to appear in the left sidebar. "project_nav_name": "PennyLane", # Set your Disqus short name to enable comments # "disqus_comments_shortname": "pennylane-1", # Set you GA account ID to enable tracking "google_analytics_account": "UA-130507810-2", # Path to a touch icon "touch_icon": "logo_new.png", # Specify a base_url used to generate sitemap.xml links. If not # specified, then no sitemap will be built. # "base_url": "" # Allow a separate homepage from the master_doc # "homepage": "index", # Allow the project link to be overriden to a custom URL. # "projectlink": "http://myproject.url", "large_toc": True, # colors "navigation_button": "#19b37b", "navigation_button_hover": "#0e714d", "toc_caption": "#19b37b", "toc_hover": "#19b37b", "table_header_bg": "#edf7f4", "table_header_border": "#19b37b", "download_button": "#19b37b", # gallery options # "github_repo": "XanaduAI/PennyLane", # "gallery_dirs": "tutorials", } edit_on_github_project = 'XanaduAI/pennylane' edit_on_github_branch = 'master/doc' # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. htmlhelp_basename = 'PennyLanedoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } latex_additional_files = ['macros.tex'] # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'PennyLane.tex', 'PennyLane Documentation', 'Xanadu Inc.', 'manual'), ] # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'pennylane', 'PennyLane Documentation', [author], 1) ] # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'PennyLane', 'PennyLane Documentation', author, 'PennyLane', 'Xanadu quantum machine learning library.', 'Miscellaneous'), ] #============================================================ # the order in which autodoc lists the documented members autodoc_member_order = 'bysource' # inheritance_diagram graphviz attributes inheritance_node_attrs = dict(color='lightskyblue1', style='filled') from directives import UsageDetails, CustomGalleryItemDirective, TitleCardDirective def setup(app): app.add_directive('customgalleryitem', CustomGalleryItemDirective) app.add_directive('titlecard', TitleCardDirective) app.add_directive("usagedetails", UsageDetails) app.add_stylesheet('xanadu_gallery.css')
/* Open a dialog for quickly changing vision and lighting parameters of the selected token(s). * This macro is adapted for WFRP4e from Token Vision Configuration by @Sky#9453 * https://github.com/Sky-Captain-13/foundry/tree/master/scriptMacros */ setTokenVisionLight(); async function setTokenVisionLight() { if (canvas.tokens.controlled.length < 1) return ui.notifications.error( game.i18n.localize("GMTOOLKIT.Token.Select"),{} ); let applyChanges = false; new Dialog({ title: game.i18n.localize("GMTOOLKIT.Dialog.SetVisionLight.Title"), content: ` <form> <div class="form-group"> <label> ${game.i18n.localize("GMTOOLKIT.Dialog.SetVisionLight.VisionType")} </label> <select id="vision-type" name="vision-type"> <option value="normalVision"> ${game.i18n.localize("GMTOOLKIT.Vision.Normal")} </option> <option value="blindedVision"> ${game.i18n.localize("GMTOOLKIT.Vision.Blinded")} </option> <option value="nightVision"> ${game.i18n.localize("GMTOOLKIT.Vision.Night")} </option> <option value="darkVision"> ${game.i18n.localize("GMTOOLKIT.Vision.Dark")} </option> <option value="noVision"> ${game.i18n.localize("GMTOOLKIT.Vision.None")} </option> </select> </div> <div class="form-group"> <label> ${game.i18n.localize("GMTOOLKIT.Dialog.SetVisionLight.LightSource")} </label> <select id="light-source" name="light-source"> <option value="none"> ${game.i18n.localize("GMTOOLKIT.LightSource.NoLight")} </option> <option value="matches"> ${game.i18n.localize("GMTOOLKIT.LightSource.Matches")} </option> <option value="candle"> ${game.i18n.localize("GMTOOLKIT.LightSource.Candle")} </option> <option value="davrich-lamp"> ${game.i18n.localize("GMTOOLKIT.LightSource.DavrichLamp")} </option> <option value="torch"> ${game.i18n.localize("GMTOOLKIT.LightSource.Torch")} </option> <option value="lantern"> ${game.i18n.localize("GMTOOLKIT.LightSource.Lantern")} </option> <option value="storm-broad"> ${game.i18n.localize("GMTOOLKIT.LightSource.StormLantern.Dim")} </option> <option value="storm-narrow"> ${game.i18n.localize("GMTOOLKIT.LightSource.StormLantern.Bright")} </option> <option value="storm-shut"> ${game.i18n.localize("GMTOOLKIT.LightSource.StormLantern.Shut")} </option> <option value="ablaze"> ${game.i18n.localize("GMTOOLKIT.LightSource.Ablaze")} </option> <option value="light"> ${game.i18n.localize("GMTOOLKIT.LightSource.Light")} </option> <option value="witchlight"> ${game.i18n.localize("GMTOOLKIT.LightSource.Witchlight")} </option> <option value="glowing-skin"> ${game.i18n.localize("GMTOOLKIT.LightSource.GlowingSkin")} </option> <option value="soulfire"> ${game.i18n.localize("GMTOOLKIT.LightSource.Soulfire")} </option> <option value="pha"> ${game.i18n.localize("GMTOOLKIT.LightSource.Pha")} </option> </select> </div> </form> `, buttons: { yes: { icon: "<i class='fas fa-check'></i>", label: game.i18n.localize("GMTOOLKIT.Dialog.Apply"), callback: () => applyChanges = true }, no: { icon: "<i class='fas fa-times'></i>", label: game.i18n.localize("GMTOOLKIT.Dialog.Cancel"), }, }, default: "yes", close: html => { if (applyChanges) { for ( let token of canvas.tokens.controlled ) { let visionType = html.find('[name="vision-type"]')[0].value || "nochange"; // TODO: default vision option based on condition -> trait -> talent. Issue Log: https://github.com/Jagusti/fvtt-wfrp4e-gmtoolkit/issues/42 let item; // used for finding whether token has Night Vision or Dark Vision let lightSource = html.find('[name="light-source"]')[0].value || "nochange"; let advNightVision = 0; let dimSight = 0; let brightSight = 0; let dimLight = 0; let brightLight = 0; // let lightAngle = 360; let lockRotation = token.data.lockRotation; let lightColor = ""; let lightColorIntensity = 0; let animationIntensity = 1; let animationSpeed = 1; let animationType = "none"; // Get Light Source Values switch (lightSource) { case "none": case "storm-shut": dimLight = 0; break; case "matches": dimLight = 5; brightLight = 2; lightColor = "#ffaa00"; lightColorIntensity = 0.3; animationIntensity = 8; animationSpeed = 8; animationType = "torch"; break; case "candle": dimLight = 10; brightLight = 5; lightColor = "#ffaa00"; lightColorIntensity = 0.3; animationIntensity = 8; animationSpeed = 8; animationType = "torch"; break; case "davrich-lamp": dimLight = 10; brightLight = 5; lightColor = "#ffaa00"; lightColorIntensity = 0.4; animationIntensity = 4; animationSpeed = 4; animationType = "torch"; break; case "torch": dimLight = 15; brightLight = 7.5; lightColor = "#ffaa00"; lightColorIntensity = 0.5; animationIntensity = 7; animationSpeed = 7; animationType = "torch" break; case "lantern": dimLight = 20; brightLight = 10; lightColor = "#ffcc66"; lightColorIntensity = 0.7; animationIntensity = 3; animationSpeed = 3; animationType = "torch"; break; case "storm-broad": dimLight = 20; brightLight = 10; lightColor = "#ffcc66"; lightColorIntensity = 0.5; animationIntensity = 1; animationSpeed = 2; animationType = "torch"; break; case "storm-narrow": dimLight = 30; brightLight = 20; lightColor = "#ffcc66"; lightColorIntensity = 0.7; animationIntensity = 1; animationSpeed = 1; animationType = "torch"; lockRotation = false; lightAngle = 60; break; case "light": dimLight = 15; brightLight = 7.5; lightColor = "#99ffff"; lightColorIntensity = 0.5; animationIntensity = 3; animationSpeed = 2; animationType = "pulse" break; case "witchlight": dimLight = 20; brightLight = 10; lightColor = "#99ffff"; lightColorIntensity = 0.7; animationIntensity = 6; animationSpeed = 2; animationType = "chroma" break; case "glowing-skin": dimLight = 10; brightLight = 3; lightColor = "#ffbd80"; lightColorIntensity = 0.3; animationIntensity = 2; animationSpeed = 2; animationType = "pulse"; break; case "ablaze": dimLight = 15; brightLight = 7.5; lightColor = "#ff7733"; lightColorIntensity = 0.5; animationIntensity = 7; animationSpeed = 7; animationType = "torch" break; case "pha": dimLight = token.actor.data.data.characteristics.wp.bonus; brightLight = token.actor.data.data.characteristics.wp.bonus; lightColor = "#ffddbb"; lightColorIntensity = 0.6; animationIntensity = 4; animationSpeed = 4; animationType = "sunburst" break; case "soulfire": dimLight = 15; brightLight = 7.5; lightColor = "#ff7733"; lightColorIntensity = 0.5; animationIntensity = 7; animationSpeed = 7; animationType = "fog" break; case "nochange": default: dimLight = token.data.dimLight; brightLight = token.data.brightLight; lightAngle = token.data.lightAngle; lockRotation = token.data.lockRotation; lightColor = token.data.lightColor; } // Get Vision Type Values switch (visionType) { case "blindedVision": brightSight = 1; dimSight = 0; break; case "noVision": dimSight = 0; brightSight = 0; dimLight = 0; brightLight = 0; break; case "darkVision": item = token.actor.items.find(i => i.data.name.toLowerCase() == game.i18n.localize("GMTOOLKIT.Trait.DarkVision").toLowerCase() ); if(item == undefined) { (game.settings.get("wfrp4e-gm-toolkit", "overrideDarkVision")) ? dimSight = Number(game.settings.get("wfrp4e-gm-toolkit", "rangeDarkVision")) : dimSight = Number(game.settings.get("wfrp4e-gm-toolkit", "rangeNormalSight")) ; } else { dimSight = Number(game.settings.get("wfrp4e-gm-toolkit", "rangeDarkVision")); } brightSight = (dimSight / 2); break; case "nightVision": // Night Vision requires some minimal illumination to provide a benefit if (game.scenes.viewed.data.darkness < 1 | dimLight > 0 | game.scenes.viewed.globalLight) { item = token.actor.items.find(i => i.data.name.toLowerCase() == game.i18n.localize("GMTOOLKIT.Talent.NightVision").toLowerCase() ); if(item == undefined) { (game.settings.get("wfrp4e-gm-toolkit", "overrideNightVision")) ? advNightVision = 1 : advNightVision = 0 ; } else { for (let item of token.actor.items) { if (item.name.toLowerCase() == game.i18n.localize("GMTOOLKIT.Talent.NightVision").toLowerCase() ) { switch (item.type) { case "trait" : advNightVision = 1; break; case "talent" : advNightVision += item.data.data.advances.value; break; } } } } brightSight = (20 * advNightVision); dimSight = Math.max(brightSight + dimLight, Number(game.settings.get("wfrp4e-gm-toolkit", "rangeNormalSight"))); } break; case "normalVision": dimSight = Number(game.settings.get("wfrp4e-gm-toolkit", "rangeNormalSight")); brightSight = 0; break; case "nochange": default: dimSight = token.data.dimSight; brightSight = token.data.brightSight; } // Update Token token.update({ vision: true, visionType: visionType, lightSource: lightSource, dimLight: dimLight, brightLight: brightLight, lightAngle: lightAngle, lightColor: lightColor, lightAlpha: lightColorIntensity, lightAnimation: { intensity: animationIntensity, speed: animationSpeed, type: animationType }, dimSight: dimSight, brightSight: brightSight, lockRotation: lockRotation, advNightVision: advNightVision }); } } } }).render(true); };
import argparse, shelve def renameDictKeys(storageDict): for key in storageDict.iterkeys(): if isinstance(storageDict[key], dict): renameDictKeys(storageDict[key]) if key == options.oldnetwork: storageDict[options.newnetwork] = storageDict[options.oldnetwork] del storageDict[options.oldnetwork] if __name__ == "__main__": # Parse the command line arguments parser = argparse.ArgumentParser(description="A tool for PyHeufyBot to migrate all storage data from one network " "to another.") parser.add_argument("-s", "--storage", help="The storage file to use", type=str, default="../heufybot.db") parser.add_argument("-o", "--oldnetwork", help="The name of the old network that the data should be migrated " "from.", type=str, required=True) parser.add_argument("-n", "--newnetwork", help="The name of the new network that the data should be migrated to.", type=str, required=True) options = parser.parse_args() storage = shelve.open(options.storage) d = dict(storage) renameDictKeys(d) storage.clear() storage.update(d) storage.close() print "Data has been migrated from '{}' to '{}'.".format(options.oldnetwork, options.newnetwork)
// Mouse events const clearBtn = document.querySelector(".clear-tasks"); const card = document.querySelector(".card"); const heading = document.querySelector("h5"); console.log(clearBtn); console.log(card); console.log(heading); /* // Click clearBtn.addEventListener("click", runEvent); //Double click clearBtn.addEventListener("dblclick", runEvent); // MouseDown (Event trigger when we click and hold the button) clearBtn.addEventListener("mousedown", runEvent); // MouseUp (Event triggers when the button is released after clicking) clearBtn.addEventListener("mouseup", runEvent); // logs when the event is executed on main element // Mouse enter card.addEventListener("mouseenter", runEvent); // Mouse leave card.addEventListener("mouseleave", runEvent); // logs when the event is executed on child element // Mouse over card.addEventListener("mouseover", runEvent); // Mouse out card.addEventListener("mouseout", runEvent); */ // Mouse move (triggers on any move inside the element ) card.addEventListener("mousemove", runEvent); // Event handler function runEvent(e) { console.log(`Event type: ${e.type}`); heading.textContent = `MouseX: ${e.offsetX} MouseY: ${e.offsetY} `; document.body.style.background = `rgb(${e.offsetX},${e.offsetY},60)`; }
!function(e){function r(r){for(var n,u,c=r[0],i=r[1],f=r[2],s=0,p=[];s<c.length;s++)u=c[s],Object.prototype.hasOwnProperty.call(o,u)&&o[u]&&p.push(o[u][0]),o[u]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(l&&l(r);p.length;)p.shift()();return a.push.apply(a,f||[]),t()}function t(){for(var e,r=0;r<a.length;r++){for(var t=a[r],n=!0,c=1;c<t.length;c++){var i=t[c];0!==o[i]&&(n=!1)}n&&(a.splice(r--,1),e=u(u.s=t[0]))}return e}var n={},o={2:0},a=[];function u(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,u),t.l=!0,t.exports}u.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var a,c=document.createElement("script");c.charset="utf-8",c.timeout=120,u.nc&&c.setAttribute("nonce",u.nc),c.src=function(e){return u.p+""+({0:"commons",1:"cd7d5f864fc9e15ed8adef086269b0aeff617554",4:"component---src-pages-404-js",5:"component---src-pages-index-js",6:"component---src-templates-blog-post-js"}[e]||e)+"-"+{0:"97f233b9450c50b916b6",1:"a7cd8781dc599bd92b1d",4:"bbdb2683a18926b48b7b",5:"6c016ba954435d04a9b6",6:"484533748e750b0ff4a6"}[e]+".js"}(e);var i=new Error;a=function(r){c.onerror=c.onload=null,clearTimeout(f);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;i.message="Loading chunk "+e+" failed.\n("+n+": "+a+")",i.name="ChunkLoadError",i.type=n,i.request=a,t[1](i)}o[e]=void 0}};var f=setTimeout((function(){a({type:"timeout",target:c})}),12e4);c.onerror=c.onload=a,document.head.appendChild(c)}return Promise.all(r)},u.m=e,u.c=n,u.d=function(e,r,t){u.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,r){if(1&r&&(e=u(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(u.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)u.d(t,n,function(r){return e[r]}.bind(null,n));return t},u.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(r,"a",r),r},u.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},u.p="/",u.oe=function(e){throw console.error(e),e};var c=window.webpackJsonp=window.webpackJsonp||[],i=c.push.bind(c);c.push=r,c=c.slice();for(var f=0;f<c.length;f++)r(c[f]);var l=i;t()}([]); //# sourceMappingURL=webpack-runtime-9fb39761c64382cb62cd.js.map
const Discord = require("discord.js"); const canvacord = require("canvacord"); module.exports.run = async (client, message, args) => { const notice3 = new Discord.MessageEmbed() .setDescription( "<:cross1:747728200691482746> **Please type the text to clyde!**" ) .setColor("RED"); const mindtxt = args.slice(0).join(" "); if (!mindtxt) return message.channel .send(notice3) .then(msg => msg.delete({ timeout: 10000 })); const image = await canvacord.Canvas.clyde(mindtxt); const triggered = new Discord.MessageAttachment(image, "clyde.png"); message.channel.send(triggered); }; module.exports.help = { name: "clyde", description: "Acts like clyde", usage: "d!clyde <text>", accessableby: "Member", aliases: [], };
import React from "react"; import {render} from 'react-dom'; import { Answer } from './Answer'; import { Banner } from './Banner'; import { Button } from './Button'; import { Numbers } from './Numbers'; import { Star } from './Star'; import { Start } from './Start'; export class App extends React.Component { constructor() { super(); this.state = { selectedNumbers: [], noOfStars: this.generateStars(), redrawsLeft: 5, correct: null, usedNumbers: [], currentLevel: 1, lives: 3, gameOver: false, gameStarted: false, messageToShow: '', counter: 0, timeFormatted: '', intervalId: 0 }; } addNumber = (clickedNumber) => { if(this.state.selectedNumbers.indexOf(clickedNumber) == -1 && this.state.usedNumbers.indexOf(clickedNumber) == -1) { this.setState( { selectedNumbers: this.state.selectedNumbers.concat(clickedNumber) } ); } } removeNumber = (clickedNumber) => { var selectedNos = this.state.selectedNumbers, indexOfNumber = selectedNos.indexOf(clickedNumber); selectedNos.splice(indexOfNumber, 1); this.setState( {selectedNumbers: selectedNos} ); } sumUpAnswers = (e) => { return this.state.selectedNumbers.reduce( (a,b) => a+b, 0); } verifyAnswer = (e) => { var correct = (this.sumUpAnswers() === this.state.noOfStars); this.setState({ correct: correct }); } redraw = (e) => { if(this.state.redrawsLeft > 0){ this.setState({ redrawsLeft: this.state.redrawsLeft - 1, noOfStars: this.generateStars() }, () => this.checkSumAvailability()); } } restartGame = (e) => { this.setState({ redrawsLeft: 5, noOfStars: this.generateStars(), usedNumbers: [], selectedNumbers: [], gameOver: false, messageToShow: '', lives: 3, correct: null, currentLevel: 1, timeFormatted: '', counter: 0, gameStarted: true }) this.startCtr(); } wrongAnswer = (e) => { if(this.state.lives > 0){ this.setState({ lives: this.state.lives - 1, noOfStars: this.generateStars(), selectedNumbers: [], correct: null }) } } generateStars = (e) => { return (Math.floor(Math.random()*9)+1); } calcHours = (e) => { return Math.floor(this.state.counter / 3600); } calcMinutes = (e) => { return Math.floor(this.state.counter / 60); } calcSeconds = (e) => { return this.state.counter % 60; } padLeft = (string, pad, length) => { return (new Array(length+1).join(pad)+string).slice(-length); } incrementCtrAndFormatTime = (e) => { this.setState({ counter: this.state.counter+1, timeFormatted: this.padLeft(this.calcHours(), '0', 2) + ':' + this.padLeft(this.calcMinutes(), '0', 2) + ':' + this.padLeft(this.calcSeconds(), '0', 2) }) } possibleCombinationSum = (arr, n) => { if (arr.indexOf(n) >= 0) { return true; } if (arr[0] > n) { return false; } if (arr[arr.length - 1] > n) { arr.pop(); return this.possibleCombinationSum(arr, n); } var listSize = arr.length, combinationsCount = (1 << listSize) for (var i = 1; i < combinationsCount ; i++ ) { var combinationSum = 0; for (var j=0 ; j < listSize ; j++) { if (i & (1 << j)) { combinationSum += arr[j]; } } if (n === combinationSum) { return true; } } return false; } startCtr = (e) => { return setInterval(this.incrementCtrAndFormatTime, 1000) } startGame = (e) => { this.setState({ gameStarted: true, intervalId: this.startCtr() }) } checkSumAvailability = (e) => { var redraws = this.state.redrawsLeft, usedNumbers = this.state.usedNumbers, noOfStars = this.state.noOfStars, possibleNumbers = []; for (var i = 1; i < 10; i++) { if(usedNumbers.indexOf(i) < 0) { possibleNumbers.push(i); } } if (redraws === 0 && !this.possibleCombinationSum(possibleNumbers, noOfStars)) { this.setState({ messageToShow: 'Game Over!(You did not have a valid combination for the number of stars generated!)', intervalId: clearInterval(this.state.intervalId), usedNumbers: [], selectedNumbers: [], gameOver: true, counter: 0, gameStarted: false, currentLevel: 0, noOfStars: 0, correct:null, timeFormatted: '' }) } } nextLevel = (e) => { if(this.state.usedNumbers.length == 8) { this.setState({ messageToShow: 'Done! Time taken: ' + this.state.timeFormatted, intervalId: clearInterval(this.state.intervalId), usedNumbers: this.state.usedNumbers.concat(this.state.selectedNumbers), noOfStars: this.generateStars(), currentLevel: this.state.currentLevel += 1, correct: null, selectedNumbers: [], gameOver: true, counter: 0, timeFormatted: '', gameStarted: false }) }else { this.setState({ usedNumbers: this.state.usedNumbers.concat(this.state.selectedNumbers), noOfStars: this.generateStars(), currentLevel: this.state.currentLevel += 1, correct: null, selectedNumbers: [] }, () => this.checkSumAvailability()) } } render() { var noOfStars = this.state.noOfStars, selectedNumbers = this.state.selectedNumbers, correct = this.state.correct, currentLevel = this.state.currentLevel, lives = this.state.lives, counter = this.state.counter, timeFormatted = this.state.timeFormatted, health = [], gameOver = this.state.gameOver, gameStarted = this.state.gameStarted, bottomFrame, midFrame; for (var i = 0; i < lives; i++) { health.push( <span key={i} className="glyphicon glyphicon-heart"></span> ) } if(!gameOver && gameStarted){ bottomFrame = ( <Numbers selectedNumbers = { this.state.selectedNumbers } addNumber = { this.addNumber } usedNumbers = { this.state.usedNumbers } gameOver = { this.state.gameOver } /> ) }else if(gameOver && !gameStarted){ bottomFrame = ( <Banner gameOver = { this.state.gameOver } messageToShow = { this.state.messageToShow } restartGame = { this.restartGame } /> ) } if(!gameStarted && !gameOver){ midFrame = ( <Start startGame = { this.startGame }/> ) }else if(gameStarted) { midFrame = ( <div> <Star noOfStars = { noOfStars } /> <div> <Button correct = { correct } selectedNumbers = { selectedNumbers } verifyAnswer = { this.verifyAnswer } nextLevel = { this.nextLevel } wrongAnswer = { this.wrongAnswer } redrawsLeft = { this.state.redrawsLeft } redraw = { this.redraw } /> <div> <Answer selectedNumbers = { this.state.selectedNumbers } removeNumber = { this.removeNumber } /> </div> </div> </div> ) } return ( <div id="game"> <h2>Algebra 4 Kids</h2> Level {currentLevel} | Lives: {health} <br/> Time: {timeFormatted} <hr/> <div className="clearfix"> {midFrame} </div> {bottomFrame} </div> ); } }
import DisplayGraphNode from 'osgUtil/DisplayGraphNode'; import RenderBin from 'osg/RenderBin'; var DisplayGraphRenderer = function(selectables) { this._selectables = selectables; this._nodeList = []; this._linkList = []; this._renderBinMap = new window.Map(); this._renderBinStack = []; this._generatorID = 0; this._refID = 0; // invalide old _instanceID if we recreate the graph this._uniqueEdges = new window.Set(); }; DisplayGraphRenderer.prototype = { getColorFromClassName: DisplayGraphNode.prototype.getColorFromClassName, createGraph: function(renderBin) { this.reset(); this.apply(renderBin); }, reset: function() { this._renderBinMap.clear(); this._renderBinStack.length = 0; this._generatorID = 0; this._refID++; this._nodeList.length = 0; this._linkList.length = 0; this._uniqueEdges.clear(); }, apply: function(rb) { var instanceID = rb.getInstanceID(); if (!this._renderBinMap.has(instanceID)) { this._renderBinMap.set(instanceID, rb); } this._renderBinStack.push(rb); // pre render stage if render stage node if (rb.getPreRenderStageList) { var preRenderList = rb.getPreRenderStageList(); for (var i = 0, ni = preRenderList.length; i < ni; ++i) { this.apply(preRenderList[i].renderStage); } } // draw implementation // handle rs camera this.registerNode(rb); // post render stage if render stage node if (rb.getPostRenderStageList) { var postRenderList = rb.getPostRenderStageList(); for (var j = 0, nj = postRenderList.length; j < nj; ++j) { this.apply(postRenderList[j].renderStage); } } this._renderBinStack.pop(); }, registerNode: function(rb) { var childID = rb.getInstanceID(); this._nodeList.push(rb); // register bins var bins = rb._bins; bins.forEach( function(key, bin) { this.apply(bin); }.bind(this) ); // register fine grained leafs if (rb._leafs.length) { for (var j = 0, nj = rb._leafs.length; j < nj; j++) { this.createNodeAndSetID(childID, rb._leafs[j]); } } var self = this; var context = {}; var leafFunction = function(leaf) { self.createNodeAndSetID(this.stateGraphID, leaf); }.bind(context); var stateGraphFunction = function(sg) { self.createNodeAndSetID(childID, sg); var stateGraphID = sg._instanceID; var leafsPool = sg.getLeafs(); context.stateGraphID = stateGraphID; leafsPool.forEach(leafFunction); }; // register coarse grained leafs var stateGraphList = rb.getStateGraphList(); stateGraphList.forEach(stateGraphFunction); // no parent no link if (this._renderBinStack.length < 2) return; var parentID = this._renderBinStack[this._renderBinStack.length - 2].getInstanceID(); this.createLink(parentID, childID); }, createLink: function(parent, child) { var key = parent + '+' + child; if (!this._uniqueEdges.has(key)) { this._linkList.push({ parentNode: parent, childrenNode: child }); this._uniqueEdges.add(key); } }, createNodeAndSetID: function(parentID, node) { // register render leaf this._nodeList.push(node); // generate fake id < 0 because RenderLeaf does not inherit from Object if ( node._instanceID === undefined || (node._instanceID < 0 && node._refID !== this._refID) ) { node._instanceID = -1 - this._generatorID++; node._refID = this._refID; } this.createLink(parentID, node._instanceID); }, generateRenderLeaf: function(g, node) { var instanceID = node._instanceID; var className = 'RenderLeaf'; var geomName = node._geometry && node._geometry.getName() ? '\n' + node._geometry.getName() : 'Geometry'; var label = className + ' ( ' + node._instanceID + ' )'; label += '\n' + geomName + ' ( ' + node._geometry.getInstanceID() + ' )'; this._selectables.set(instanceID.toString(), node); g.addNode(instanceID, { label: label, description: '', style: 'fill: ' + this.getColorFromClassName(className) + ';stroke-width: 0px;' }); }, generateStateGraph: function(g, node) { var instanceID = node._instanceID; var className = 'StateGraph'; var label = className + ' ( ' + node._instanceID + ' )'; label += '\n' + node._leafs._length + ' leafs'; this._selectables.set(instanceID.toString(), node); g.addNode(instanceID, { label: label, description: '', style: 'fill: ' + this.getColorFromClassName(className) + ';stroke-width: 0px;' }); }, generateRenderStage: function(g, node) { var label = node.className() + ' ( ' + node._instanceID + ' )'; if (node.getName()) label += '\n' + node.getName(); label += '\nViewport ( ' + node.getViewport().width() + ' x ' + node.getViewport().height() + ' )'; this._selectables.set(node.getInstanceID().toString(), node); g.addNode(node.getInstanceID(), { label: label, description: '', style: 'fill: ' + this.getColorFromClassName(node.className()) + ';stroke-width: 0px;' }); }, generateRenderBin: function(g, rb) { var label = rb.className() + ' ( ' + rb.getInstanceID() + ' )'; if (rb.getName()) label += '\n' + rb.getName(); var sortMode = ''; if (rb.getSortMode() === RenderBin.SORT_BACK_TO_FRONT) sortMode = 'SortMode: BackToFront'; var description = 'BinNumber: ' + rb.getBinNumber() + '\n' + sortMode; this._selectables.set(rb.getInstanceID().toString(), rb); g.addNode(rb.getInstanceID(), { label: label, description: description, style: 'fill: ' + this.getColorFromClassName(rb.className()) + ';stroke-width: 0px;' }); }, // Subfunction of createGraph, will iterate to create all the node and link in dagre generateNodeAndLink: function(g) { for (var i = 0, ni = this._nodeList.length; i < ni; i++) { var node = this._nodeList[i]; // detect if RenderLeaf if (node._geometry && node._depth !== undefined) { this.generateRenderLeaf(g, node); } else if (node.className() === 'StateGraph') { this.generateStateGraph(g, node); } else if (node.className() === 'RenderStage') { this.generateRenderStage(g, node); } else { // it's a RenderBin this.generateRenderBin(g, node); } } for (var j = 0, nj = this._linkList.length; j < nj; j++) { g.addEdge(null, this._linkList[j].parentNode, this._linkList[j].childrenNode); } } }; export default DisplayGraphRenderer;
var settings = hammerhead.get('./settings'); var urlUtils = hammerhead.get('./utils/url'); var sharedUrlUtils = hammerhead.get('../utils/url'); var destLocation = hammerhead.get('./utils/destination-location'); var browserUtils = hammerhead.utils.browser; var nativeMethods = hammerhead.nativeMethods; var nodeSandbox = hammerhead.sandbox.node; var Promise = hammerhead.Promise; var PROXY_PORT = 1337; var PROXY_HOSTNAME = '127.0.0.1'; var PROXY_HOST = PROXY_HOSTNAME + ':' + PROXY_PORT; function getProxyUrl (url, resourceType, protocol, windowId) { return urlUtils.getProxyUrl(url, { proxyHostname: PROXY_HOSTNAME, proxyPort: PROXY_PORT, sessionId: 'sessionId', resourceType: resourceType, proxyProtocol: protocol || 'http:', windowId: windowId }); } test('getCrossDomainIframeProxyUrl (GH-749)', function () { var destUrl = 'test.html'; var storedCrossDomainport = settings.get().crossDomainProxyPort; settings.get().crossDomainProxyPort = '5555'; strictEqual(urlUtils.getCrossDomainIframeProxyUrl(destUrl), 'http://' + location.hostname + ':5555' + '/sessionId!i/https://example.com/' + destUrl); settings.get().crossDomainProxyPort = storedCrossDomainport; }); test('resolveUrlAsDest', function () { strictEqual(urlUtils.resolveUrlAsDest('/index.html#hash'), 'https://example.com/index.html#hash'); strictEqual(urlUtils.resolveUrlAsDest('javascript:0;'), 'javascript:0;'); strictEqual(urlUtils.resolveUrlAsDest('/index.html?param=value#hash'), 'https://example.com/index.html?param=value#hash'); strictEqual(urlUtils.resolveUrlAsDest('https://twitter.com/index.html?param=value#hash'), 'https://twitter.com/index.html?param=value#hash'); strictEqual(urlUtils.resolveUrlAsDest('//twitter.com/index.html?param=value#hash'), 'https://twitter.com/index.html?param=value#hash'); strictEqual(urlUtils.resolveUrlAsDest('http://g.tbcdn.cn/??kissy/k/1.4.2/seed-min.js'), 'http://g.tbcdn.cn/??kissy/k/1.4.2/seed-min.js'); }); test('isSupportedProtocol', function () { ok(urlUtils.isSupportedProtocol('http://example.org')); ok(urlUtils.isSupportedProtocol('https://example.org')); ok(urlUtils.isSupportedProtocol('file:///C:/index.htm')); ok(urlUtils.isSupportedProtocol('//example.org')); ok(urlUtils.isSupportedProtocol('/some/path')); ok(urlUtils.isSupportedProtocol('path')); ok(urlUtils.isSupportedProtocol('./')); ok(urlUtils.isSupportedProtocol('../../')); ok(urlUtils.isSupportedProtocol('?t')); ok(!urlUtils.isSupportedProtocol('#42')); ok(!urlUtils.isSupportedProtocol(' data:asdasdasdasdasdasd')); ok(!urlUtils.isSupportedProtocol('chrome-extension://google.com/image.png')); }); test('formatUrl', function () { strictEqual(urlUtils.formatUrl({ hostname: 'localhost', partAfterHost: '/path' }), '/path'); strictEqual(urlUtils.formatUrl({ port: '1400', partAfterHost: '/path' }), '/path'); strictEqual(urlUtils.formatUrl({ hostname: 'localhost', port: '1400', protocol: 'http:' }), 'http://localhost:1400'); var parsedUrl = { hostname: 'localhost', port: '1400', protocol: 'http:', auth: 'test:test' }; strictEqual(urlUtils.formatUrl(parsedUrl), 'http://test:test@localhost:1400'); parsedUrl = { hostname: 'localhost', port: '1400', protocol: 'http:', auth: 'test', partAfterHost: '/path' }; strictEqual(urlUtils.formatUrl(parsedUrl), 'http://test@localhost:1400/path'); }); test('isRelativeUrl', function () { ok(!sharedUrlUtils.isRelativeUrl('http://example.com')); ok(sharedUrlUtils.isRelativeUrl('/test.html')); ok(!sharedUrlUtils.isRelativeUrl('file:///C:/index.htm')); ok(sharedUrlUtils.isRelativeUrl('C:\\index.htm')); }); module('parse url'); test('newline characters', function () { var url = 'http://exa\nmple.com/?par\n=val'; var parsingResult = urlUtils.parseUrl(url); strictEqual(parsingResult.hostname, 'example.com'); strictEqual(parsingResult.partAfterHost, '/?par=val'); }); test('tabulation characters', function () { var url = 'http://exa\tmple.com/?par\t=val'; var parsingResult = urlUtils.parseUrl(url); strictEqual(parsingResult.hostname, 'example.com'); strictEqual(parsingResult.partAfterHost, '/?par=val'); }); test('hash after host', function () { var url = '//test.example.com#42'; var parsingResult = urlUtils.parseUrl(url); ok(!parsingResult.protocol); strictEqual(parsingResult.hostname, 'test.example.com'); strictEqual(parsingResult.partAfterHost, '#42'); }); test('question mark disappears', function () { var url = 'http://google.ru:345/path?'; var parsedUrl = urlUtils.parseUrl(url); strictEqual(parsedUrl.partAfterHost, '/path?'); strictEqual(urlUtils.formatUrl(parsedUrl), url); url = 'http://yandex.ru:234/path'; parsedUrl = urlUtils.parseUrl(url); strictEqual(parsedUrl.partAfterHost, '/path'); strictEqual(urlUtils.formatUrl(parsedUrl), url); }); test('additional slashes after scheme (GH-739)', function () { var url = 'http://///example.com/'; var parsingResult = urlUtils.parseUrl(url); strictEqual(parsingResult.hostname, 'example.com'); urlUtils.parseUrl('////mail.ru'); }); test('additional slashes before path', function () { var url = '/////example.com/'; var parsingResult = urlUtils.parseUrl(url); strictEqual(parsingResult.hostname, 'example.com'); }); test('auth', function () { strictEqual(urlUtils.parseUrl('http://username:[email protected]').auth, 'username:password'); strictEqual(urlUtils.parseUrl('http://[email protected]').auth, 'username'); strictEqual(urlUtils.parseUrl('http://example.com').auth, void 0); }); module('get proxy url'); test('already proxied', function () { var destUrl = 'http://test.example.com/'; var proxyUrl = getProxyUrl(destUrl); var newUrl = getProxyUrl(proxyUrl, 'i'); strictEqual(urlUtils.parseProxyUrl(newUrl).resourceType, 'i'); }); test('destination with query, path, hash and host', function () { var destUrl = 'http://test.example.com/pa/th/Page?param1=value&param2=&param3#testHash'; var proxyUrl = getProxyUrl(destUrl); strictEqual(proxyUrl, 'http://' + PROXY_HOST + '/sessionId/' + destUrl); }); test('destination with host only', function () { var destUrl = 'http://test.example.com/'; var proxyUrl = getProxyUrl(destUrl); strictEqual(proxyUrl, 'http://' + PROXY_HOST + '/sessionId/' + destUrl); }); test('destination with https protocol', function () { var destUrl = 'https://test.example.com:53/'; var proxyUrl = getProxyUrl(destUrl); strictEqual(proxyUrl, 'http://' + PROXY_HOST + '/sessionId/' + destUrl); }); test('relative path', function () { var proxyUrl = urlUtils.getProxyUrl('/Image1.jpg'); strictEqual(proxyUrl, 'http://' + location.host + '/sessionId/https://example.com/Image1.jpg'); var parsedUrl = urlUtils.parseUrl('share?id=1kjQMWh7IcHdTBbTv6otRvCGYr-p02q206M7aR7dmog0'); ok(!parsedUrl.hostname); ok(!parsedUrl.host); ok(!parsedUrl.hash); ok(!parsedUrl.port); ok(!parsedUrl.protocol); strictEqual(parsedUrl.partAfterHost, 'share?id=1kjQMWh7IcHdTBbTv6otRvCGYr-p02q206M7aR7dmog0'); }); if (window.navigator.platform.toLowerCase() === 'win32' && !browserUtils.isFirefox) { test('relative file path', function () { var destUrl = 'C:\\index.htm'; var proxyUrl = urlUtils.getProxyUrl(destUrl); strictEqual(proxyUrl, 'http://' + location.host + '/sessionId/file:///C:/index.htm'); }); } test('contains successive question marks in query', function () { var destUrl = 'http://test.example.com/??dirs/???files/'; var proxyUrl = urlUtils.getProxyUrl(destUrl, { proxyHostname: '127.0.0.1', proxyPort: PROXY_PORT, sessionId: 'sessionId' }); strictEqual(proxyUrl, 'http://' + PROXY_HOST + '/sessionId/' + destUrl); }); test('destination with port', function () { var destUrl = 'http://test.example.com:53/'; var proxyUrl = getProxyUrl(destUrl); strictEqual(proxyUrl, 'http://' + PROXY_HOST + '/sessionId/' + destUrl); }); test('undefined or null', function () { // NOTE: In Safari, a.href = null leads to the empty url, not <current_url>/null. if (!browserUtils.isSafari) strictEqual(getProxyUrl(null), 'http://' + PROXY_HOST + '/sessionId/https://example.com/null'); strictEqual(getProxyUrl(void 0), 'http://' + PROXY_HOST + '/sessionId/https://example.com/undefined'); }); test('remove unnecessary slashes form the begin of the url', function () { var proxy = urlUtils.getProxyUrl('/////example.com', { proxyHostname: 'localhost', proxyPort: '5555', sessionId: 'sessionId', resourceType: 'resourceType' }); strictEqual(proxy, 'http://localhost:5555/sessionId!resourceType/https://example.com'); }); test('should ensure triple starting slashes in a scheme-less file URLs', function () { var storedLocation = destLocation.getLocation(); destLocation.forceLocation(urlUtils.getProxyUrl('file:///home/testcafe/site')); var opts = { proxyHostname: 'localhost' }; strictEqual(urlUtils.getProxyUrl('/////home/testcafe/site2', opts), 'http://localhost:2000/sessionId/file:///home/testcafe/site2'); strictEqual(urlUtils.getProxyUrl('/////D:/testcafe/site2', opts), 'http://localhost:2000/sessionId/file:///D:/testcafe/site2'); strictEqual(urlUtils.getProxyUrl('//D:/testcafe/site2', opts), 'http://localhost:2000/sessionId/file:///D:/testcafe/site2'); destLocation.forceLocation(storedLocation); }); test('convert destination host and protocol to lower case', function () { // BUG: GH-1 var proxy = getProxyUrl('hTtp://eXamPle.Com:123/paTh/Image?Name=Value&#Hash'); ok(proxy.indexOf('http://example.com:123/paTh/Image?Name=Value&#Hash') !== -1); }); test('unexpected trailing slash (GH-342)', function () { var proxyUrl = getProxyUrl('http://example.com'); ok(!/\/$/.test(proxyUrl)); proxyUrl = getProxyUrl('http://example.com/'); ok(/\/$/.test(proxyUrl)); }); test('special pages (GH-339)', function () { sharedUrlUtils.SPECIAL_PAGES.forEach(function (url) { var proxyUrl = getProxyUrl(url); strictEqual(proxyUrl, 'http://' + PROXY_HOST + '/sessionId/' + url); }); }); test('convert a charset to lower case (GH-752)', function () { var url = 'http://example.com'; var opts = { sessionId: 'sessionId', charset: 'UTF-8', proxyHostname: 'localhost', proxyPort: '5555' }; strictEqual(sharedUrlUtils.getProxyUrl(url, opts), 'http://localhost:5555/sessionId!utf-8/' + url); }); test('windowId', function () { var destUrl = 'http://example.com'; var proxyUrl = getProxyUrl(destUrl, null, null, '123456789'); strictEqual(proxyUrl, 'http://' + PROXY_HOST + '/sessionId' + '*123456789/' + destUrl); }); test('getPageProxyUrl', function () { var sameDomainUrl = 'https://example.com/'; var crossDomainUrl = 'https://devexpress.com/'; var proxySameDomainHost = location.host; var proxyCrossDomainHost = location.hostname + ':' + settings.get().crossDomainProxyPort; strictEqual(urlUtils.getPageProxyUrl(sameDomainUrl, 'windowId'), 'http://' + proxySameDomainHost + '/sessionId*windowId/' + sameDomainUrl); strictEqual(urlUtils.getPageProxyUrl(crossDomainUrl, 'windowId'), 'http://' + proxyCrossDomainHost + '/sessionId*windowId/' + crossDomainUrl); strictEqual(urlUtils.getPageProxyUrl('http://' + proxySameDomainHost + '/sessionId*pa/' + sameDomainUrl, 'windowId'), 'http://' + proxySameDomainHost + '/sessionId*windowId/' + sameDomainUrl); strictEqual(urlUtils.getPageProxyUrl('http://' + proxySameDomainHost + '/sessionId*pa!if/' + sameDomainUrl, 'windowId'), 'http://' + proxySameDomainHost + '/sessionId*windowId!f/' + sameDomainUrl); strictEqual(urlUtils.getPageProxyUrl('http://' + proxyCrossDomainHost + '/sessionId*pa!i/' + sameDomainUrl, 'windowId'), 'http://' + proxySameDomainHost + '/sessionId*windowId/' + sameDomainUrl); }); module('https proxy protocol'); test('destination with host only', function () { var destUrl = 'http://test.example.com/'; var proxyUrl = getProxyUrl(destUrl, '', 'https:'); strictEqual(proxyUrl, 'https://' + PROXY_HOST + '/sessionId/' + destUrl); }); test('relative path', function () { var proxyUrl = getProxyUrl('/Image1.jpg', '', 'https:'); strictEqual(proxyUrl, 'https://' + PROXY_HOST + '/sessionId/https://example.com/Image1.jpg'); }); test('special pages', function () { sharedUrlUtils.SPECIAL_PAGES.forEach(function (url) { var proxyUrl = getProxyUrl(url, '', 'https:'); strictEqual(proxyUrl, 'https://' + PROXY_HOST + '/sessionId/' + url); }); }); test('parse proxy url', function () { var proxyUrl = 'https://' + PROXY_HOST + '/sessionId/http://test.example.com:53/PA/TH/?#testHash'; var parsingResult = urlUtils.parseProxyUrl(proxyUrl); strictEqual(parsingResult.destUrl, 'http://test.example.com:53/PA/TH/?#testHash'); strictEqual(parsingResult.destResourceInfo.protocol, 'http:'); strictEqual(parsingResult.destResourceInfo.host, 'test.example.com:53'); strictEqual(parsingResult.destResourceInfo.hostname, 'test.example.com'); strictEqual(parsingResult.destResourceInfo.port, '53'); strictEqual(parsingResult.destResourceInfo.partAfterHost, '/PA/TH/?#testHash'); strictEqual(parsingResult.sessionId, 'sessionId'); }); module('parse proxy url'); test('http', function () { var proxyUrl = 'http://' + PROXY_HOST + '/sessionId/http://test.example.com:53/PA/TH/?#testHash'; var parsingResult = urlUtils.parseProxyUrl(proxyUrl); strictEqual(parsingResult.destUrl, 'http://test.example.com:53/PA/TH/?#testHash'); strictEqual(parsingResult.destResourceInfo.protocol, 'http:'); strictEqual(parsingResult.destResourceInfo.host, 'test.example.com:53'); strictEqual(parsingResult.destResourceInfo.hostname, 'test.example.com'); strictEqual(parsingResult.destResourceInfo.port, '53'); strictEqual(parsingResult.destResourceInfo.partAfterHost, '/PA/TH/?#testHash'); strictEqual(parsingResult.sessionId, 'sessionId'); }); test('https', function () { var proxyUrl = 'http://' + PROXY_HOST + '/sessionId/https://test.example.com:53/PA/TH/?#testHash'; var parsingResult = urlUtils.parseProxyUrl(proxyUrl); strictEqual(parsingResult.destUrl, 'https://test.example.com:53/PA/TH/?#testHash'); strictEqual(parsingResult.destResourceInfo.protocol, 'https:'); strictEqual(parsingResult.destResourceInfo.host, 'test.example.com:53'); strictEqual(parsingResult.destResourceInfo.hostname, 'test.example.com'); strictEqual(parsingResult.destResourceInfo.port, '53'); strictEqual(parsingResult.destResourceInfo.partAfterHost, '/PA/TH/?#testHash'); strictEqual(parsingResult.sessionId, 'sessionId'); }); test('non-proxy URL', function () { var proxyUrl = 'http://' + PROXY_HOST + '/PA/TH/?someParam=value'; var destUrlInfo = urlUtils.parseProxyUrl(proxyUrl); ok(!destUrlInfo); }); test('successive question marks', function () { var proxyUrl = 'http://' + PROXY_HOST + '/sessionId/http://test.example.com:53??dirs/???files/&#testHash'; var parsingResult = urlUtils.parseProxyUrl(proxyUrl); strictEqual(parsingResult.destUrl, 'http://test.example.com:53??dirs/???files/&#testHash'); strictEqual(parsingResult.destResourceInfo.protocol, 'http:'); strictEqual(parsingResult.destResourceInfo.host, 'test.example.com:53'); strictEqual(parsingResult.destResourceInfo.hostname, 'test.example.com'); strictEqual(parsingResult.destResourceInfo.port, '53'); strictEqual(parsingResult.destResourceInfo.partAfterHost, '??dirs/???files/&#testHash'); strictEqual(parsingResult.sessionId, 'sessionId'); }); test('single question mark', function () { var url = 'http://ac-gb.marketgid.com/p/j/2865/11?'; var proxyUtrl = urlUtils.getProxyUrl(url, { proxyHostname: 'hostname', proxyPort: 1111, sessionId: 'sessionId' }); strictEqual(url, urlUtils.formatUrl(urlUtils.parseProxyUrl(proxyUtrl).destResourceInfo)); }); test('special pages (GH-339)', function () { sharedUrlUtils.SPECIAL_PAGES.forEach(function (url) { var proxyUrl = 'http://' + PROXY_HOST + '/sessionId/' + url; var parsingResult = urlUtils.parseProxyUrl(proxyUrl); strictEqual(parsingResult.destUrl, url); strictEqual(parsingResult.destResourceInfo.protocol, 'about:'); strictEqual(parsingResult.destResourceInfo.host, ''); strictEqual(parsingResult.destResourceInfo.hostname, ''); strictEqual(parsingResult.destResourceInfo.port, ''); strictEqual(parsingResult.destResourceInfo.partAfterHost, ''); strictEqual(parsingResult.sessionId, 'sessionId'); }); }); test('special page with hash (GH-1671)', function () { var specialPageUrlWithHash = 'about:error#hash'; var proxyUrl = 'http://' + PROXY_HOST + '/sessionId/' + specialPageUrlWithHash; var parsingResult = urlUtils.parseProxyUrl(proxyUrl); strictEqual(parsingResult.destUrl, specialPageUrlWithHash); strictEqual(parsingResult.destResourceInfo.protocol, 'about:'); strictEqual(parsingResult.destResourceInfo.host, ''); strictEqual(parsingResult.destResourceInfo.hostname, ''); strictEqual(parsingResult.destResourceInfo.port, ''); strictEqual(parsingResult.destResourceInfo.partAfterHost, ''); strictEqual(parsingResult.sessionId, 'sessionId'); }); test('hash with whitespace (GH-971)', function () { var url = 'http://' + PROXY_HOST + '/sessionId/http://some.domain.com/path/#word word'; var parsingResult = urlUtils.parseProxyUrl(url); strictEqual(parsingResult.sessionId, 'sessionId'); strictEqual(parsingResult.destUrl, 'http://some.domain.com/path/#word word'); strictEqual(parsingResult.destResourceInfo.partAfterHost, '/path/#word word'); }); test('windowId', function () { var proxyUrl = 'http://' + PROXY_HOST + '/sessionId*123456789/http://example.com'; var parsedProxyUrl = urlUtils.parseProxyUrl(proxyUrl); strictEqual(parsedProxyUrl.destUrl, 'http://example.com'); strictEqual(parsedProxyUrl.sessionId, 'sessionId'); strictEqual(parsedProxyUrl.resourceType, null); strictEqual(parsedProxyUrl.windowId, '123456789'); }); module('change proxy url'); test('destination URL part', function () { var proxyUrl = 'http://localhost:1337/sessionId/http://test.example.com:53/#testHash'; var changed = urlUtils.changeDestUrlPart(proxyUrl, nativeMethods.anchorPortSetter, '34'); strictEqual(changed, 'http://localhost:1337/sessionId/http://test.example.com:34/#testHash'); changed = urlUtils.changeDestUrlPart(proxyUrl, nativeMethods.anchorHostSetter, 'newhost:99'); strictEqual(changed, 'http://localhost:1337/sessionId/http://newhost:99/#testHash'); changed = urlUtils.changeDestUrlPart(proxyUrl, nativeMethods.anchorHostnameSetter, 'newhostname'); strictEqual(changed, 'http://localhost:1337/sessionId/http://newhostname:53/#testHash'); changed = urlUtils.changeDestUrlPart(proxyUrl, nativeMethods.anchorProtocolSetter, 'https:'); strictEqual(changed, 'http://localhost:1337/sessionId/https://test.example.com:53/#testHash'); changed = urlUtils.changeDestUrlPart(proxyUrl, nativeMethods.anchorPathnameSetter, 'test1.html'); strictEqual(changed, 'http://localhost:1337/sessionId/http://test.example.com:53/test1.html#testHash'); changed = urlUtils.changeDestUrlPart(proxyUrl, nativeMethods.anchorSearchSetter, '?hl=ru&tab=wn'); strictEqual(changed, 'http://localhost:1337/sessionId/http://test.example.com:53/?hl=ru&tab=wn#testHash'); }); module('regression'); test('location.port must return the empty string (T262593)', function () { eval(processScript([ // NOTE: From att.com, iframesrc === https://att.com:null/?IFRAME. 'var port = (document.location.port == "") ? "" : (":" + document.location.port);', 'var iframesrc = document.location.protocol + "//" + document.location.hostname + port + "/" + "?IFRAME";' ].join('\n'))); // eslint-disable-next-line no-undef strictEqual(iframesrc, 'https://example.com/?IFRAME'); }); test('a correct proxy URL should be obtained from a destination that has a URL in its path (GH-471)', function () { var destUrl = 'https://example.com/path/path/sdfjhsdkjf/http://example.com/image.png'; var proxyUrl = getProxyUrl(destUrl); strictEqual(proxyUrl, 'http://' + PROXY_HOST + '/sessionId/' + destUrl); }); module('getProxyUrl in a document with "base" tag'); test('add, update and remove the "base" tag (GH-371)', function () { strictEqual(getProxyUrl('image.png'), 'http://' + PROXY_HOST + '/sessionId/https://example.com/image.png'); var baseEl = document.createElement('base'); strictEqual(getProxyUrl('image.png'), 'http://' + PROXY_HOST + '/sessionId/https://example.com/image.png'); baseEl.setAttribute('href', 'http://subdomain.example.com'); document.head.appendChild(baseEl); strictEqual(getProxyUrl('image.png'), 'http://' + PROXY_HOST + '/sessionId/http://subdomain.example.com/image.png'); baseEl.setAttribute('href', 'http://example2.com'); strictEqual(getProxyUrl('image.png'), 'http://' + PROXY_HOST + '/sessionId/http://example2.com/image.png'); baseEl.removeAttribute('href'); strictEqual(getProxyUrl('image.png'), 'http://' + PROXY_HOST + '/sessionId/https://example.com/image.png'); baseEl.parentNode.removeChild(baseEl); strictEqual(getProxyUrl('image.png'), 'http://' + PROXY_HOST + '/sessionId/https://example.com/image.png'); }); test('recreating a document with the "base" tag (GH-371)', function () { var src = getSameDomainPageUrl('../../data/same-domain/resolving-url-after-document-recreation.html'); return createTestIframe({ src: src }) .then(function (iframe) { var iframeDocument = iframe.contentDocument; var anchor = iframeDocument.getElementsByTagName('a')[0]; var proxyUrl = 'http://' + location.hostname + ':' + location.port + '/sessionId!i/http://subdomain.example.com/index.html'; strictEqual(nativeMethods.anchorHrefGetter.call(anchor), proxyUrl); }); }); test('setting up an href attribute for a non-added to DOM "base" tag should not cause urlResolver to update. (GH-415)', function () { var baseEl = document.createElement('base'); baseEl.setAttribute('href', 'http://subdomain.example.com'); strictEqual(getProxyUrl('image.png'), 'http://' + PROXY_HOST + '/sessionId/https://example.com/image.png'); }); test('"base" tag with an empty href attribute (GH-422)', function () { var base = document.createElement('base'); document.head.appendChild(base); strictEqual(getProxyUrl('image.png'), 'http://' + PROXY_HOST + '/sessionId/https://example.com/image.png'); base.setAttribute('href', ''); strictEqual(getProxyUrl('image.png'), 'http://' + PROXY_HOST + '/sessionId/https://example.com/image.png'); }); test('"base" tag with an href attribute that is set to a relative url (GH-422)', function () { var base = document.createElement('base'); document.head.appendChild(base); base.setAttribute('href', '/test1/test2/test3'); strictEqual(getProxyUrl('../image.png'), 'http://' + PROXY_HOST + '/sessionId/https://example.com/test1/image.png'); base.parentNode.removeChild(base); }); test('resolving url after writing the "base" tag (GH-526)', function () { var src = getSameDomainPageUrl('../../data/same-domain/resolving-url-after-writing-base-tag.html'); return createTestIframe({ src: src }) .then(function (iframe) { var anchor = iframe.contentDocument.querySelector('a'); var proxyUrl = urlUtils.getProxyUrl('http://example.com/relative', { proxyHostname: location.hostname, proxyPort: location.port, sessionId: 'sessionId', resourceType: 'i' }); strictEqual(nativeMethods.anchorHrefGetter.call(anchor), proxyUrl); }); }); test('"base" tag with an href attribute that is set to a protocol relative url (GH-568)', function () { var base = document.createElement('base'); document.head.appendChild(base); base.setAttribute('href', '//test.com'); strictEqual(getProxyUrl('/image.png'), 'http://' + PROXY_HOST + '/sessionId/https://test.com/image.png'); base.parentNode.removeChild(base); }); test('resolving a url in a tag that is written along with a "base" tag (GH-644)', function () { var iframe = document.createElement('iframe'); iframe.id = 'test902345'; document.body.appendChild(iframe); iframe.contentDocument.write( '<base href="/subpath/"/>', '<!DOCTYPE html>', '<html>', '<head><script src="scripts/scr.js"><' + '/script></head>', '...', '</html>' ); strictEqual(nativeMethods.scriptSrcGetter.call(iframe.contentDocument.querySelector('script')), 'http://' + location.host + '/sessionId!s/https://example.com/subpath/scripts/scr.js'); document.body.removeChild(iframe); }); test('only first base tag should be affected', function () { var storedProcessElement = nodeSandbox._processElement; var nativeIframe = nativeMethods.createElement.call(document, 'iframe'); var proxiedIframe = null; nodeSandbox._processElement = function (el) { if (el !== nativeIframe) storedProcessElement.call(nodeSandbox, el); }; function checkTestCase (name, fn) { fn(nativeIframe.contentDocument); fn(proxiedIframe.contentDocument); var nativeAnchor = nativeIframe.contentDocument.querySelector('a'); var proxiedAnchor = proxiedIframe.contentDocument.querySelector('a'); nativeAnchor.setAttribute('href', 'path'); proxiedAnchor.setAttribute('href', 'path'); strictEqual(urlUtils.parseProxyUrl(nativeMethods.anchorHrefGetter.call(proxiedAnchor)).destUrl, nativeAnchor.href, name); } return createTestIframe() .then(function (iframe) { proxiedIframe = iframe; return new Promise(function (resolve) { const nativeAddEventListener = nativeMethods.documentAddEventListener || nativeMethods.addEventListener; nativeAddEventListener.call(nativeIframe, 'load', resolve); nativeMethods.appendChild.call(document.body, nativeIframe); }); }) .then(function () { checkTestCase('append first base', function (doc) { var anchor = doc.createElement('a'); var base = doc.createElement('base'); anchor.textContent = 'link'; base.setAttribute('href', 'https://example.com/123/'); doc.head.appendChild(base); doc.body.appendChild(anchor); }); checkTestCase('create base', function (doc) { doc.createElement('base'); }); checkTestCase('create base and set attribute', function (doc) { doc.createElement('base').setAttribute('href', 'http://example.com/base/'); }); checkTestCase('append second base', function (doc) { var base = doc.createElement('base'); base.setAttribute('href', 'https://example.com/some/'); doc.head.appendChild(base); }); checkTestCase('change first base', function (doc) { var base = doc.querySelectorAll('base')[0]; base.setAttribute('href', 'https://example.com/something/'); }); checkTestCase('change second base', function (doc) { var base = doc.querySelectorAll('base')[1]; base.setAttribute('href', 'https://example.com/something/'); }); checkTestCase('remove second base', function (doc) { var base = doc.querySelectorAll('base')[1]; doc.head.removeChild(base); }); checkTestCase('append second base', function (doc) { var base = doc.createElement('base'); base.setAttribute('href', 'https://example.com/some/'); doc.head.appendChild(base); }); checkTestCase('remove first base', function (doc) { var base = doc.querySelectorAll('base')[0]; doc.head.removeChild(base); }); checkTestCase('append base to fragment', function (doc) { var fragment = doc.createDocumentFragment(); var base = doc.createElement('base'); base.setAttribute('href', 'https://example.com/fragment/'); fragment.appendChild(base); }); checkTestCase('innerHtml', function (doc) { doc.head.innerHTML = '<base href="https://example.com/inner-html/">'; }); checkTestCase('insert first base without href', function (doc) { var base = doc.createElement('base'); document.head.insertBefore(base, document.head.firstChild); }); }) .then(function () { nativeMethods.removeChild.call(document.body, nativeIframe); nodeSandbox._processElement = storedProcessElement; }); });
import time import logging import tensorflow as tf s = tf.Session() x = tf.constant([1.0, 2.0]) y = x * 2 logging.basicConfig() logger = logging.getLogger('helloworld') logger.setLevel(10) while True: logger.info(s.run(y)) time.sleep(10)
'use strict'; import { ret, mat4, mul, sub, add } from '../utils'; export default function (funcName = 'rotate', x = 0.0, y = 0.0, z = 1.0) { return [ `mat4 ${funcName}(float angle) {`, 'float s = sin(angle);', 'float c = cos(angle);', 'float oc = 1.0 - c;', ret( mat4( add( mul('oc', x*x), 'c' ), sub( mul('oc', x*y), mul(z, 's') ), add( mul('oc', z*x), mul(y, 's') ), 0, add( mul('oc', x*y), mul(z, 's') ), add( mul('oc', y*y), 'c' ), sub( mul('oc', y*z), mul(x, 's') ), 0, sub( mul('oc', z*x), mul(y, 's') ), add( mul('oc', y*z), mul(x, 's') ), add( mul('oc', z*z), 'c' ) ) ), '}', ]; }
import React from 'react'; import { Badge, Tooltip } from '@patternfly/react-core'; export const TEXT_FILTER = 'hostname_or_id'; export const TEXTUAL_CHIP = 'textual'; export const TAG_CHIP = 'tags'; export const STALE_CHIP = 'staleness'; export const REGISTERED_CHIP = 'registered_with'; export function constructValues(groupValue) { return Object.entries(groupValue).map(([ key, { isSelected, group, item }]) => { if (isSelected) { const { tag: { key: tagKey, value: tagValue } } = item.meta; return { key, tagKey, value: tagValue, name: `${tagKey}=${tagValue}`, group }; } }).filter(Boolean); } export function mapGroups(currSelection, valuesKey = 'values') { return Object.entries(currSelection).map(([ groupKey, groupValue ]) => { const values = constructValues(groupValue, groupKey); if (values && values.length > 0) { return { type: 'tags', key: groupKey, category: values[0].group.label, [valuesKey]: values }; } }).filter(Boolean); } export function filterToGroup(filter = [], valuesKey = 'values') { return filter.reduce((accGroup, group) => ({ ...accGroup, [group.key]: group[valuesKey].reduce((acc, curr) => ({ ...acc, [curr.key]: { isSelected: true, group: curr.group, item: { meta: { tag: { key: curr.key, value: curr.value } } } } }), {}) }), {}); } export function constructGroups(allTags) { return allTags.map(({ name, tags }) => ({ label: name, value: name, type: 'checkbox', items: tags.map(({ count, tag: { key: tagKey, value } }) => ({ label: <React.Fragment> <div>{tagKey}={value}</div> <Tooltip position="right" enableFlip content={`Applicable to ${count} system${count === 1 ? '' : 's'}.`} > <Badge isRead={count <= 0}>{ count }</Badge> </Tooltip> </React.Fragment>, meta: { count, tag: { key: tagKey, value } }, value: tagKey })) })); } export const arrayToSelection = (selected) => selected.reduce((acc, { cells: [ key, value, namespace ] }) => ({ ...acc, [namespace]: { ...acc[namespace?.title || namespace], [key?.title || key]: { isSelected: true, group: { value: namespace?.title || namespace, label: namespace?.title || namespace }, item: { value: key?.title || key, meta: { tag: { key: key?.title || key, value: value?.title || value } } } } } }), {}); export const defaultFilters = { staleFilter: [ 'fresh', 'stale' ], registeredWithFilter: [ 'insights' ] }; export function reduceFilters(filters) { return filters.reduce((acc, oneFilter) => { if (oneFilter.value === TEXT_FILTER) { return { ...acc, textFilter: oneFilter.filter }; } else if ('tagFilters' in oneFilter) { return { ...acc, tagFilters: filterToGroup(oneFilter.tagFilters) }; } else if ('staleFilter' in oneFilter) { return { ...acc, staleFilter: oneFilter.staleFilter }; } else if ('registeredWithFilter' in oneFilter) { return { ...acc, registeredWithFilter: oneFilter.registeredWithFilter }; } return acc; }, { textFilter: '', tagFilters: {}, ...defaultFilters }); } export const mergeTableProps = (stateProps, dispatchProps, ownProps) => ({ ...dispatchProps, ...ownProps, ...stateProps, ...ownProps.onRefresh && { onRefresh: (...props) => { dispatchProps.onRefresh(...props); ownProps.onRefresh(...props); } } }); export const tagsFilterBuilder = (onFilter, onChange, selected, loaded, tags, items = [], loader) => ({ label: 'Tags', value: 'tags', type: 'group', placeholder: 'Filter system by tag', filterValues: { className: 'ins-c-inventory__tags-filter', onFilter, onChange: (_e, newSelection, group, item, groupKey, itemKey) => { if (item.meta) { const isSelected = newSelection[groupKey][itemKey]; newSelection[groupKey][itemKey] = { isSelected, group, item }; onChange(newSelection); } }, selected, ...loaded && tags.length > 0 ? { groups: [ ...constructGroups(tags), ...items ] } : { items: [ { label: !loaded ? loader : <div className="ins-c-inventory__tags-no-tags"> No tags available </div>, isDisabled: true, className: 'ins-c-inventory__tags-tail' } ] } } }); export const staleness = [ { label: 'Fresh', value: 'fresh' }, { label: 'Stale', value: 'stale' }, { label: 'Stale warning', value: 'stale_warning' } ]; export const registered = [ { label: 'Insights', value: 'insights' } ];
import pytest import stk from ..case_data import GenericCaseData @pytest.fixture def primary_amino(get_atom_ids): a, b, c, d = get_atom_ids(4) return _primary_amino(stk.N(a), stk.H(b), stk.H(c), stk.C(d)) def _primary_amino(nitrogen, hydrogen1, hydrogen2, atom): bonders = (nitrogen, ) deleters = (hydrogen1, hydrogen2) return GenericCaseData( functional_group=stk.PrimaryAmino( nitrogen=nitrogen, hydrogen1=hydrogen1, hydrogen2=hydrogen2, atom=atom, bonders=bonders, deleters=deleters, ), atoms=(nitrogen, hydrogen1, hydrogen2, atom), bonders=bonders, deleters=deleters, )
import typescript from "rollup-plugin-typescript2"; export default { input: "HelloWorld.ts", output: { file: "../dist/box2d-helloworld.umd.js", name: "helloworld", format: "umd" }, plugins: [ typescript({ clean: true, tsconfigOverride: { compilerOptions: { target: "ES2015", module: "ES2015" } } }), ] };
const theme_settings = { '10-31': 'theme-halloween.css', '11-1': 'theme-halloween.css', '12-24': 'theme-christmas.css', '12-25': 'theme-christmas.css', '12-26': 'theme-christmas.css', } const theme_date = new Date(); const date_key = (theme_date.getMonth()+1) + '-' + theme_date.getDate(); if(date_key in theme_settings) { document.write('<link href="css/'+theme_settings[date_key]+'" rel="stylesheet">'); } else { document.write('<link href="css/theme-normal.css" rel="stylesheet">'); }
RocketChat.Migrations.add({ version: 105, up() { if (RocketChat && RocketChat.models) { if (RocketChat.models.Users) { RocketChat.models.Users.find({ 'settings.preferences.unreadRoomsMode': { $exists: 1 } }).forEach(function(user) { const newPreference = user.settings.preferences.unreadRoomsMode ? 'unread' : 'category'; RocketChat.models.Users.update({ _id: user._id }, { $unset: { 'settings.preferences.unreadRoomsMode': 1 }, $set: { 'settings.preferences.roomsListExhibitionMode': newPreference } }); }); } if (RocketChat.models.Settings) { const settingsMap = { Desktop_Notifications_Default_Alert: 'Accounts_Default_User_Preferences_desktopNotifications', Mobile_Notifications_Default_Alert: 'Accounts_Default_User_Preferences_mobileNotifications', Audio_Notifications_Default_Alert: 'Accounts_Default_User_Preferences_audioNotifications', Desktop_Notifications_Duration: 'Accounts_Default_User_Preferences_desktopNotificationDuration', Audio_Notifications_Value: undefined, }; RocketChat.models.Settings.find({ _id: { $in: Object.keys(settingsMap) } }).forEach((oldSetting) => { const newSettingKey = settingsMap[oldSetting._id]; const newSetting = newSettingKey && RocketChat.models.Settings.findOne({ _id: newSettingKey }); if (newSetting && newSetting.value !== oldSetting.value) { RocketChat.models.Settings.update({ _id: newSettingKey }, { $set: { value: oldSetting.value } }); } RocketChat.models.Settings.remove({ _id: oldSetting._id }); }); } } }, });
# -*- coding: utf-8 -*- """ @object: PHEME @task: Main function of GAN-RNN: both Generater & discriminator are RNN (2 classes) @author: ma jing @module: sequence words input, GAN @variable: Nepoch, lr_g, lr_d @time: May 20, 2019 """ import sys reload(sys) sys.setdefaultencoding('utf-8') import os from model_GAN_RNN import GAN from train import * from evaluate import * from Util import * import numpy as np from numpy.testing import assert_array_almost_equal import time import datetime import random ## variable ## vocabulary_size = 5000 hidden_dim = 100 Nclass = 2 Nepoch = 201 # main epoch Nepoch_G = 51 # pre-Train G Nepoch_D = 101 # pre-Train D lr_g = 0.005 lr_d = 0.005 obj = "pheme"#"test-" # dataset fold = "0" unit="GAN-RNN-"+obj+str(fold) modelPath = "../param/param-"+unit+".npz" unit_dis="RNN-"+obj+str(fold) modelPath_dis = "../param/param-"+unit_dis+".npz" unit_pre="GAN-RNN-pre-"+obj+str(fold) modelPath_pre = "../param/param-"+unit_pre+".npz" trainPath = "../nfold/TrainSet_"+obj+fold+".txt" testPath = "../nfold/TestSet_"+obj+fold+".txt" labelPath = "../resource/"+obj+"-label_balance.txt" textPath = '../resource/'+obj+'.vol_5000.txt' ################################### tools ##################################### def dic2matrix(dicW): # format: dicW = {ts:[index:wordfreq]} X = [] keyset = dicW.keys() timestamps = sorted(keyset) for ts in timestamps: x = [0 for i in range(vocabulary_size)] for pair in dicW[ts]: x[ int(pair.split(':')[0]) ] = int(pair.split(':')[1]) X.append( x ) return X labelset_true = ['true', 'non-rumour'] labelset_false = ['false', 'rumour'] def loadLabel(label): if label in labelset_true: y_train = [1,0] y_train_gen = [0,1] if label in labelset_false: y_train = [0,1] y_train_gen = [1,0] return y_train, y_train_gen ################################# loas data ################################### def loadData(): print "loading labels", labelDic = {} for line in open(labelPath): line = line.rstrip() eid, label = line.split('\t')[0], line.split('\t')[1] labelDic[eid] = label print len(labelDic) print "reading events", ## X textDic = {} for line in open(textPath): line = line.rstrip() if len(line.split('\t')) < 3: continue eid, ts, Vec = line.split('\t')[0], int(line.split('\t')[1]), line.split('\t')[2].split(' ') if textDic.has_key(eid): textDic[eid][ts] = Vec else: textDic[eid] = {ts: Vec} print len(textDic) print "loading train set", x_word_train, y_train, y_gen_train, Len_train, c = [], [], [], [], 0 index_true, index_false = [], [] for eid in open(trainPath): #if c > 8: break eid = eid.rstrip() if not labelDic.has_key(eid): continue if not textDic.has_key(eid): continue ## 1. load label label = labelDic[eid] if label in labelset_true: index_true.append(c) if label in labelset_false: index_false.append(c) y, y_gen = loadLabel(label) y_train.append(y) y_gen_train.append(y_gen) Len_train.append( len(textDic[eid]) ) wordFreq = dic2matrix( textDic[eid] ) x_word_train.append( wordFreq ) c += 1 print c print "loading test set", x_word_test, y_test, Len_test, c = [], [], [], 0 for eid in open(testPath): #if c > 4: break eid = eid.rstrip() if not labelDic.has_key(eid): continue if not textDic.has_key(eid): continue ## 1. load label label = labelDic[eid] y, y_gen = loadLabel(label) y_test.append(y) Len_test.append( len(textDic[eid]) ) wordFreq = dic2matrix( textDic[eid] ) x_word_test.append( wordFreq ) c += 1 print c #print "train no:", len(x_word_train), len(y_train), len(y_gen_train), len(Len_train) #print "test no:", len(x_word_test), len(y_test), len(Len_test) #print "dim1 for 0:", len(x_word_train[0]), len(x_word_train[0][0]), y_train[0], y_gen_train[0], Len_train[0] #exit(0) return x_word_train, y_train, y_gen_train, Len_train, x_word_test, y_test, index_true, index_false ##################################### MAIN #################################### ## 1. load tree & word & index & label x_word_train, y_train, yg_train, Len_train, x_word_test, y_test, index_true, index_false = loadData() ## 2. ini RNN model t0 = time.time() GANmodel = GAN(vocabulary_size, hidden_dim, Nclass) t1 = time.time() print 'GAN-RNN model established,', (t1-t0)/60 ## 3. pre-train or load model if os.path.isfile(modelPath): GANmodel = load_model(modelPath, GANmodel) lr_d, lr_g = 0.0001, 0.0001 else: # pre train classifier if os.path.isfile(modelPath_dis): GANmodel = load_model_dis(modelPath_dis, GANmodel) #lr_d = 0.005 else: pre_train_Discriminator(GANmodel, x_word_train, y_train, x_word_test, y_test, lr_d, Nepoch_D, modelPath_dis) #exit(0) # pre train generator if os.path.isfile(modelPath_pre): GANmodel = load_model(modelPath_pre, GANmodel) #pre_train_Generator('rn', GANmodel, x_word_train, x_index_train, index_false, Len_train, y_train, yg_train, lr_g, Nepoch_G, modelPath_pre, floss) #lr_g = 0.005 else: pre_train_Generator('nr', GANmodel, x_word_train, index_true, Len_train, y_train, yg_train, lr_g, Nepoch_G, modelPath_pre) pre_train_Generator('rn', GANmodel, x_word_train, index_false, Len_train, y_train, yg_train, lr_g, Nepoch_G, modelPath_pre) #lr_g = 0.0001''' train_Gen_Dis(GANmodel, x_word_train,Len_train, y_train, yg_train, index_true, index_false, x_word_test, y_test, lr_g, lr_d, Nepoch, modelPath)
module.exports = { module: { rules: [ { test: /\.coffee$/, loader: 'coffee-loader', }, ], }, };
#!/usr/bin/env python3 # pylint: disable=E1101 import os import importlib import unittest from collections import defaultdict, Counter from typing import List, Optional, Tuple from parameterized import parameterized_class from cereal import log, car from common.realtime import DT_CTRL from selfdrive.boardd.boardd import can_capnp_to_can_list, can_list_to_can_capnp from selfdrive.car.fingerprints import all_known_cars from selfdrive.car.car_helpers import interfaces from selfdrive.car.gm.values import CAR as GM from selfdrive.car.honda.values import CAR as HONDA, HONDA_BOSCH from selfdrive.car.hyundai.values import CAR as HYUNDAI from selfdrive.car.tests.routes import non_tested_cars, routes, TestRoute from selfdrive.test.openpilotci import get_url from tools.lib.logreader import LogReader from panda.tests.safety import libpandasafety_py from panda.tests.safety.common import package_can_msg PandaType = log.PandaState.PandaType NUM_JOBS = int(os.environ.get("NUM_JOBS", "1")) JOB_ID = int(os.environ.get("JOB_ID", "0")) ignore_addr_checks_valid = [ GM.BUICK_REGAL, HYUNDAI.GENESIS_G70_2020, ] # build list of test cases routes_by_car = defaultdict(set) for r in routes: routes_by_car[r.car_fingerprint].add(r) test_cases: List[Tuple[str, Optional[TestRoute]]] = [] for i, c in enumerate(sorted(all_known_cars())): if i % NUM_JOBS == JOB_ID: test_cases.extend((c, r) for r in routes_by_car.get(c, (None, ))) SKIP_ENV_VAR = "SKIP_LONG_TESTS" @parameterized_class(('car_model', 'test_route'), test_cases) class TestCarModel(unittest.TestCase): @unittest.skipIf(SKIP_ENV_VAR in os.environ, f"Long running test skipped. Unset {SKIP_ENV_VAR} to run") @classmethod def setUpClass(cls): if cls.test_route is None: if cls.car_model in non_tested_cars: print(f"Skipping tests for {cls.car_model}: missing route") raise unittest.SkipTest raise Exception(f"missing test route for {cls.car_model}") disable_radar = False test_segs = (2, 1, 0) if cls.test_route.segment is not None: test_segs = (cls.test_route.segment,) for seg in test_segs: try: lr = LogReader(get_url(cls.test_route.route, seg)) except Exception: continue can_msgs = [] fingerprint = defaultdict(dict) for msg in lr: if msg.which() == "can": for m in msg.can: if m.src < 64: fingerprint[m.src][m.address] = len(m.dat) can_msgs.append(msg) elif msg.which() == "carParams": if msg.carParams.openpilotLongitudinalControl: disable_radar = True if len(can_msgs) > int(50 / DT_CTRL): break else: raise Exception(f"Route: {repr(cls.test_route.route)} with segments: {test_segs} not found or no CAN msgs found. Is it uploaded?") cls.can_msgs = sorted(can_msgs, key=lambda msg: msg.logMonoTime) cls.CarInterface, cls.CarController, cls.CarState = interfaces[cls.car_model] cls.CP = cls.CarInterface.get_params(cls.car_model, fingerprint, [], disable_radar) assert cls.CP assert cls.CP.carFingerprint == cls.car_model def setUp(self): self.CI = self.CarInterface(self.CP, self.CarController, self.CarState) assert self.CI # TODO: check safetyModel is in release panda build self.safety = libpandasafety_py.libpandasafety cfg = self.CP.safetyConfigs[-1] set_status = self.safety.set_safety_hooks(cfg.safetyModel.raw, cfg.safetyParam) self.assertEqual(0, set_status, f"failed to set safetyModel {cfg}") self.safety.init_tests() def test_car_params(self): if self.CP.dashcamOnly: self.skipTest("no need to check carParams for dashcamOnly") # make sure car params are within a valid range self.assertGreater(self.CP.mass, 1) self.assertGreater(self.CP.steerRateCost, 1e-3) if self.CP.steerControlType != car.CarParams.SteerControlType.angle: tuning = self.CP.lateralTuning.which() if tuning == 'pid': self.assertTrue(len(self.CP.lateralTuning.pid.kpV)) elif tuning == 'torque': self.assertTrue(self.CP.lateralTuning.torque.kf > 0) elif tuning == 'indi': self.assertTrue(len(self.CP.lateralTuning.indi.outerLoopGainV)) else: raise Exception("unkown tuning") def test_car_interface(self): # TODO: also check for checkusm and counter violations from can parser can_invalid_cnt = 0 CC = car.CarControl.new_message() for i, msg in enumerate(self.can_msgs): CS = self.CI.update(CC, (msg.as_builder().to_bytes(),)) self.CI.apply(CC) # wait 2s for low frequency msgs to be seen if i > 200: can_invalid_cnt += not CS.canValid self.assertLess(can_invalid_cnt, 50) def test_radar_interface(self): os.environ['NO_RADAR_SLEEP'] = "1" RadarInterface = importlib.import_module(f'selfdrive.car.{self.CP.carName}.radar_interface').RadarInterface RI = RadarInterface(self.CP) assert RI error_cnt = 0 for i, msg in enumerate(self.can_msgs): rr = RI.update((msg.as_builder().to_bytes(),)) if rr is not None and i > 50: error_cnt += car.RadarData.Error.canError in rr.errors self.assertEqual(error_cnt, 0) def test_panda_safety_rx_valid(self): if self.CP.dashcamOnly: self.skipTest("no need to check panda safety for dashcamOnly") start_ts = self.can_msgs[0].logMonoTime failed_addrs = Counter() for can in self.can_msgs: # update panda timer t = (can.logMonoTime - start_ts) / 1e3 self.safety.set_timer(int(t)) # run all msgs through the safety RX hook for msg in can.can: if msg.src >= 64: continue to_send = package_can_msg([msg.address, 0, msg.dat, msg.src % 4]) if self.safety.safety_rx_hook(to_send) != 1: failed_addrs[hex(msg.address)] += 1 # ensure all msgs defined in the addr checks are valid if self.car_model not in ignore_addr_checks_valid: self.safety.safety_tick_current_rx_checks() if t > 1e6: self.assertTrue(self.safety.addr_checks_valid()) self.assertFalse(len(failed_addrs), f"panda safety RX check failed: {failed_addrs}") def test_panda_safety_carstate(self): """ Assert that panda safety matches openpilot's carState """ if self.CP.dashcamOnly: self.skipTest("no need to check panda safety for dashcamOnly") CC = car.CarControl.new_message() # warm up pass, as initial states may be different for can in self.can_msgs[:300]: for msg in can_capnp_to_can_list(can.can, src_filter=range(64)): to_send = package_can_msg(msg) self.safety.safety_rx_hook(to_send) self.CI.update(CC, (can_list_to_can_capnp([msg, ]), )) if not self.CP.pcmCruise: self.safety.set_controls_allowed(0) controls_allowed_prev = False CS_prev = car.CarState.new_message() checks = defaultdict(lambda: 0) for can in self.can_msgs: CS = self.CI.update(CC, (can.as_builder().to_bytes(), )) for msg in can_capnp_to_can_list(can.can, src_filter=range(64)): to_send = package_can_msg(msg) ret = self.safety.safety_rx_hook(to_send) self.assertEqual(1, ret, f"safety rx failed ({ret=}): {to_send}") # TODO: check rest of panda's carstate (steering, ACC main on, etc.) checks['gasPressed'] += CS.gasPressed != self.safety.get_gas_pressed_prev() # TODO: remove this exception once this mismatch is resolved brake_pressed = CS.brakePressed if CS.brakePressed and not self.safety.get_brake_pressed_prev(): if self.CP.carFingerprint in (HONDA.PILOT, HONDA.PASSPORT, HONDA.RIDGELINE) and CS.brake > 0.05: brake_pressed = False checks['brakePressed'] += brake_pressed != self.safety.get_brake_pressed_prev() if self.CP.pcmCruise: # On most pcmCruise cars, openpilot's state is always tied to the PCM's cruise state. # On Honda Nidec, we always engage on the rising edge of the PCM cruise state, but # openpilot brakes to zero even if the min ACC speed is non-zero (i.e. the PCM disengages). if self.CP.carName == "honda" and self.CP.carFingerprint not in HONDA_BOSCH: # only the rising edges are expected to match if CS.cruiseState.enabled and not CS_prev.cruiseState.enabled: checks['controlsAllowed'] += not self.safety.get_controls_allowed() else: checks['controlsAllowed'] += not CS.cruiseState.enabled and self.safety.get_controls_allowed() else: # Check for enable events on rising edge of controls allowed button_enable = any(evt.enable for evt in CS.events) mismatch = button_enable != (self.safety.get_controls_allowed() and not controls_allowed_prev) checks['controlsAllowed'] += mismatch controls_allowed_prev = self.safety.get_controls_allowed() if button_enable and not mismatch: self.safety.set_controls_allowed(False) if self.CP.carName == "honda": checks['mainOn'] += CS.cruiseState.available != self.safety.get_acc_main_on() # TODO: fix standstill mismatches for other makes checks['standstill'] += CS.standstill == self.safety.get_vehicle_moving() CS_prev = CS failed_checks = {k: v for k, v in checks.items() if v > 0} self.assertFalse(len(failed_checks), f"panda safety doesn't agree with openpilot: {failed_checks}") if __name__ == "__main__": unittest.main()
import { getAttributes } from '@carbon/icon-helpers'; import PropTypes from 'prop-types'; import React from 'react'; function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } var defaultStyle = { "willChange": "transform" }; var Migrate20 = React.forwardRef(function (_ref, ref) { var className = _ref.className, children = _ref.children, style = _ref.style, tabIndex = _ref.tabIndex, rest = _objectWithoutProperties(_ref, ["className", "children", "style", "tabIndex"]); var _getAttributes = getAttributes(_objectSpread({}, rest, { tabindex: tabIndex })), tabindex = _getAttributes.tabindex, props = _objectWithoutProperties(_getAttributes, ["tabindex"]); if (className) { props.className = className; } if (tabindex !== undefined && tabindex !== null) { props.tabIndex = tabindex; } if (_typeof(style) === 'object') { props.style = _objectSpread({}, defaultStyle, style); } else { props.style = defaultStyle; } if (ref) { props.ref = ref; } return React.createElement('svg', props, children, React.createElement('path', { d: 'M26 2H6a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h9v6.17l-2.59-2.58L11 15l5 5 5-5-1.41-1.41L17 16.17V10h9a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2zM6 4h4v4H6zm20 4H12V4h14zm0 14H6a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h20a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2zM6 24h14v4H6zm20 4h-4v-4h4z' })); }); Migrate20.displayName = 'Migrate20'; Migrate20.propTypes = { 'aria-hidden': PropTypes.bool, 'aria-label': PropTypes.string, 'aria-labelledby': PropTypes.string, className: PropTypes.string, children: PropTypes.node, height: PropTypes.number, preserveAspectRatio: PropTypes.string, tabIndex: PropTypes.string, viewBox: PropTypes.string, width: PropTypes.number, xmlns: PropTypes.string }; Migrate20.defaultProps = { width: 20, height: 20, viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg', preserveAspectRatio: 'xMidYMid meet' }; export default Migrate20;
import express from "express"; import PostController from "../controllers/postController"; const router = express.Router(); // router.param('id', PostController.findById); // api/v1/posts router.route("/posts").get(PostController.get).post(PostController.create); router .route("/posts/:id") .get(PostController.getPost) .delete(PostController.remove); // .put(PostController.update) export default router;
'use strict'; angular.module("ngLocale", [], ["$provide", function($provide) { var PLURAL_CATEGORY = {ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "many", OTHER: "other"}; $provide.value("$locale", { "DATETIME_FORMATS": { "AMPMS": [ "AM", "PM" ], "DAY": [ "igandea", "astelehena", "asteartea", "asteazkena", "osteguna", "ostirala", "larunbata" ], "MONTH": [ "urtarrila", "otsaila", "martxoa", "apirila", "maiatza", "ekaina", "uztaila", "abuztua", "iraila", "urria", "azaroa", "abendua" ], "SHORTDAY": [ "ig", "al", "as", "az", "og", "or", "lr" ], "SHORTMONTH": [ "urt", "ots", "mar", "api", "mai", "eka", "uzt", "abu", "ira", "urr", "aza", "abe" ], "fullDate": "EEEE, y'eko' MMMM'ren' dd'a'", "longDate": "y'eko' MMM'ren' dd'a'", "medium": "y MMM d HH:mm:ss", "mediumDate": "y MMM d", "mediumTime": "HH:mm:ss", "short": "yyyy-MM-dd HH:mm", "shortDate": "yyyy-MM-dd", "shortTime": "HH:mm" }, "NUMBER_FORMATS": { "CURRENCY_SYM": "\u20ac", "DECIMAL_SEP": ",", "GROUP_SEP": ".", "PATTERNS": [ { "gSize": 3, "lgSize": 3, "macFrac": 0, "maxFrac": 3, "minFrac": 0, "minInt": 1, "negPre": "-", "negSuf": "", "posPre": "", "posSuf": "" }, { "gSize": 3, "lgSize": 3, "macFrac": 0, "maxFrac": 2, "minFrac": 2, "minInt": 1, "negPre": "(", "negSuf": "\u00a0\u00a4)", "posPre": "", "posSuf": "\u00a0\u00a4" } ] }, "id": "eu-es", "pluralCat": function (n) { if (n == 1) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;} }); }]);
__all__ = ['editor.Editor','editorcontainer.EditorContainer']
// The Module object: Our interface to the outside world. We import // and export values on it, and do the work to get that through // closure compiler if necessary. There are various ways Module can be used: // 1. Not defined. We create it here // 2. A function parameter, function(Module) { ..generated code.. } // 3. pre-run appended it, var Module = {}; ..generated code.. // 4. External script tag defines var Module. // We need to do an eval in order to handle the closure compiler // case, where this code here is minified but Module was defined // elsewhere (e.g. case 4 above). We also need to check if Module // already exists (e.g. case 3 above). // Note that if you want to run closure, and also to use Module // after the generated code, you will need to define var Module = {}; // before the code. Then that object will be used in the code, and you // can continue to use Module afterwards as well. var Module; if (!Module) Module = (typeof Module !== 'undefined' ? Module : null) || {}; // Sometimes an existing Module object exists with properties // meant to overwrite the default module functionality. Here // we collect those properties and reapply _after_ we configure // the current environment's defaults to avoid having to be so // defensive during initialization. var moduleOverrides = {}; for (var key in Module) { if (Module.hasOwnProperty(key)) { moduleOverrides[key] = Module[key]; } } // The environment setup code below is customized to use Module. // *** Environment setup code *** var ENVIRONMENT_IS_WEB = typeof window === 'object'; // Three configurations we can be running in: // 1) We could be the application main() thread running in the main JS UI thread. (ENVIRONMENT_IS_WORKER == false and ENVIRONMENT_IS_PTHREAD == false) // 2) We could be the application main() thread proxied to worker. (with Emscripten -s PROXY_TO_WORKER=1) (ENVIRONMENT_IS_WORKER == true, ENVIRONMENT_IS_PTHREAD == false) // 3) We could be an application pthread running in a worker. (ENVIRONMENT_IS_WORKER == true and ENVIRONMENT_IS_PTHREAD == true) var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function'; var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function' && !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER; var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER; if (ENVIRONMENT_IS_NODE) { // Expose functionality in the same simple way that the shells work // Note that we pollute the global namespace here, otherwise we break in node if (!Module['print']) Module['print'] = function print(x) { process['stdout'].write(x + '\n'); }; if (!Module['printErr']) Module['printErr'] = function printErr(x) { process['stderr'].write(x + '\n'); }; var nodeFS = require('fs'); var nodePath = require('path'); Module['read'] = function read(filename, binary) { filename = nodePath['normalize'](filename); var ret = nodeFS['readFileSync'](filename); // The path is absolute if the normalized version is the same as the resolved. if (!ret && filename != nodePath['resolve'](filename)) { filename = path.join(__dirname, '..', 'src', filename); ret = nodeFS['readFileSync'](filename); } if (ret && !binary) ret = ret.toString(); return ret; }; Module['readBinary'] = function readBinary(filename) { var ret = Module['read'](filename, true); if (!ret.buffer) { ret = new Uint8Array(ret); } assert(ret.buffer); return ret; }; Module['load'] = function load(f) { globalEval(read(f)); }; if (!Module['thisProgram']) { if (process['argv'].length > 1) { 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) { // suppress ExitStatus exceptions from showing an error 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; // not present in v8 or older sm 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 { // Probably a worker, and without console.log. We can do very little here... var TRY_USE_DUMP = false; if (!Module['print']) Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) { dump(x); }) : (function(x) { // self.postMessage(x); // enable this if you want stdout to be sent as messages })); } if (ENVIRONMENT_IS_WORKER) { Module['load'] = importScripts; } if (typeof Module['setWindowTitle'] === 'undefined') { Module['setWindowTitle'] = function(title) { document.title = title }; } } else { // Unreachable because SHELL is dependant on the others 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'; } // *** Environment setup code *** // Closure helpers Module.print = Module['print']; Module.printErr = Module['printErr']; // Callbacks Module['preRun'] = []; Module['postRun'] = []; // Merge back in the overrides for (var key in moduleOverrides) { if (moduleOverrides.hasOwnProperty(key)) { Module[key] = moduleOverrides[key]; } } // === Preamble library stuff === // Documentation for the public APIs defined in this file must be updated in: // site/source/docs/api_reference/preamble.js.rst // A prebuilt local version of the documentation is available at: // site/build/text/docs/api_reference/preamble.js.txt // You can also build docs locally as HTML or other formats in site/ // An online HTML version (which may be of a different version of Emscripten) // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html //======================================== // Runtime code shared with compiler //======================================== 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; // A pointer } 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') { // move so the load is aligned if (ptr & 7) { assert((ptr & 7) === 4); ptr += 4; } } else { assert((ptr & 3) === 0); } return ptr; }, getAlignSize: function (type, size, vararg) { // we align i64s and doubles on 64-bit boundaries, unlike x86 if (!vararg && (type == 'i64' || type == 'double')) return 8; if (!type) return Math.min(size, 8); // align structures internally to 64 bits return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE); }, dynCall: function (sig, ptr, args) { if (args && args.length) { assert(args.length == sig.length-1); if (!args.splice) args = Array.prototype.slice.call(args); args.splice(0, 0, ptr); assert(('dynCall_' + sig) in Module, 'bad function pointer type - no table for sig \'' + sig + '\''); return Module['dynCall_' + sig].apply(null, args); } else { assert(sig.length == 1); assert(('dynCall_' + sig) in Module, 'bad function pointer type - no table for sig \'' + sig + '\''); return Module['dynCall_' + sig].call(null, ptr); } }, functionPointers: [], addFunction: function (func) { for (var i = 0; i < Runtime.functionPointers.length; i++) { if (!Runtime.functionPointers[i]) { Runtime.functionPointers[i] = func; return 2*(1 + i); } } throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.'; }, removeFunction: function (index) { Runtime.functionPointers[(index-2)/2] = null; }, warnOnce: function (text) { if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {}; if (!Runtime.warnOnce.shown[text]) { Runtime.warnOnce.shown[text] = 1; Module.printErr(text); } }, funcWrappers: {}, getFuncWrapper: function (func, sig) { assert(sig); if (!Runtime.funcWrappers[sig]) { Runtime.funcWrappers[sig] = {}; } var sigCache = Runtime.funcWrappers[sig]; if (!sigCache[func]) { sigCache[func] = function dynCall_wrapper() { return Runtime.dynCall(sig, func, arguments); }; } return sigCache[func]; }, getCompilerSetting: function (name) { throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work'; }, stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+15)&-16);(assert((((STACKTOP|0) < (STACK_MAX|0))|0))|0); return ret; }, staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + (assert(!staticSealed),size))|0;STATICTOP = (((STATICTOP)+15)&-16); return ret; }, dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + (assert(DYNAMICTOP > 0),size))|0;DYNAMICTOP = (((DYNAMICTOP)+15)&-16); if (DYNAMICTOP >= 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.0)) : ((+((low>>>0)))+((+((high|0)))*4294967296.0))); return ret; }, GLOBAL_BASE: 8, QUANTUM_SIZE: 4, __dummy__: 0 } Module["Runtime"] = Runtime; //======================================== // Runtime essentials //======================================== var __THREW__ = 0; // Used in checking for thrown exceptions. var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort() var EXITSTATUS = 0; var undef = 0; // tempInt is used for 32-bit signed values or smaller. tempBigInt is used // for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt 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; // Returns the C function with a specified identifier (for C++, you need to do manual name mangling) function getCFunc(ident) { var func = Module['_' + ident]; // closure exported function if (!func) { try { func = eval('_' + ident); // explicit lookup } catch(e) {} } assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)'); return func; } var cwrap, ccall; (function(){ var JSfuncs = { // Helpers for cwrap -- it can't refer to Runtime directly because it might // be renamed by closure, instead it calls JSfuncs['stackSave'].body to find // out what the minified function name is. 'stackSave': function() { Runtime.stackSave() }, 'stackRestore': function() { Runtime.stackRestore() }, // type conversion from js to c '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) { // null string // at most 4 bytes per UTF-8 code point, +1 for the trailing '\0' ret = Runtime.stackAlloc((str.length << 2) + 1); writeStringToMemory(str, ret); } return ret; } }; // For fast lookup of conversion functions var toC = {'string' : JSfuncs['stringToC'], 'array' : JSfuncs['arrayToC']}; // C calling interface. ccall = function ccallFunc(ident, returnType, argTypes, args, opts) { var func = getCFunc(ident); var cArgs = []; var stack = 0; assert(returnType !== 'array', 'Return type should not be "array".'); if (args) { for (var i = 0; i < args.length; i++) { var converter = toC[argTypes[i]]; if (converter) { if (stack === 0) stack = Runtime.stackSave(); cArgs[i] = converter(args[i]); } else { cArgs[i] = args[i]; } } } var ret = func.apply(null, cArgs); if ((!opts || !opts.async) && typeof EmterpreterAsync === 'object') { assert(!EmterpreterAsync.state, 'cannot start async op with normal JS calling ccall'); } if (opts && opts.async) assert(!returnType, 'async ccalls cannot return values'); if (returnType === 'string') ret = Pointer_stringify(ret); if (stack !== 0) { if (opts && opts.async) { EmterpreterAsync.asyncFinalizers.push(function() { Runtime.stackRestore(stack); }); return; } Runtime.stackRestore(stack); } return ret; } var sourceRegex = /^function\s*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/; function parseJSFunc(jsfunc) { // Match the body and the return value of a javascript function source var parsed = jsfunc.toString().match(sourceRegex).slice(1); return {arguments : parsed[0], body : parsed[1], returnValue: parsed[2]} } var JSsource = {}; for (var fun in JSfuncs) { if (JSfuncs.hasOwnProperty(fun)) { // Elements of toCsource are arrays of three items: // the code, and the return value JSsource[fun] = parseJSFunc(JSfuncs[fun]); } } cwrap = function cwrap(ident, returnType, argTypes) { argTypes = argTypes || []; var cfunc = getCFunc(ident); // When the function takes numbers and returns a number, we can just return // the original function var numericArgs = argTypes.every(function(type){ return type === 'number'}); var numericRet = (returnType !== 'string'); if ( numericRet && numericArgs) { return cfunc; } // Creation of the arguments list (["$1","$2",...,"$nargs"]) var argNames = argTypes.map(function(x,i){return '$'+i}); var funcstr = "(function(" + argNames.join(',') + ") {"; var nargs = argTypes.length; if (!numericArgs) { // Generate the code needed to convert the arguments from javascript // values to pointers funcstr += 'var stack = ' + JSsource['stackSave'].body + ';'; for (var i = 0; i < nargs; i++) { var arg = argNames[i], type = argTypes[i]; if (type === 'number') continue; var convertCode = JSsource[type + 'ToC']; // [code, return] funcstr += 'var ' + convertCode.arguments + ' = ' + arg + ';'; funcstr += convertCode.body + ';'; funcstr += arg + '=' + convertCode.returnValue + ';'; } } // When the code is compressed, the name of cfunc is not literally 'cfunc' anymore var cfuncname = parseJSFunc(function(){return cfunc}).returnValue; // Call the function funcstr += 'var ret = ' + cfuncname + '(' + argNames.join(',') + ');'; if (!numericRet) { // Return type can only by 'string' or 'number' // Convert the result to a string var strgfy = parseJSFunc(function(){return Pointer_stringify}).returnValue; funcstr += 'ret = ' + strgfy + '(ret);'; } funcstr += "if (typeof EmterpreterAsync === 'object') { assert(!EmterpreterAsync.state, 'cannot start async op with normal JS calling cwrap') }"; if (!numericArgs) { // If we had a stack, restore it funcstr += JSsource['stackRestore'].body.replace('()', '(stack)') + ';'; } funcstr += 'return ret})'; return eval(funcstr); }; })(); Module["ccall"] = ccall; Module["cwrap"] = cwrap; function setValue(ptr, value, type, noSafe) { type = type || 'i8'; if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit switch(type) { case 'i1': HEAP8[((ptr)>>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.0 ? (tempDouble > 0.0 ? ((Math_min((+(Math_floor((tempDouble)/4294967296.0))), 4294967295.0))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>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'; // pointers are 32-bit 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; // Tries to use _malloc() var ALLOC_STACK = 1; // Lives for the duration of the current function call var ALLOC_STATIC = 2; // Cannot be freed var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk var ALLOC_NONE = 4; // Do not allocate 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; // allocate(): This is for internal use. You can use it yourself as well, but the interface // is a little tricky (see docs right below). The reason is that it is optimized // for multiple syntaxes to save space in generated code. So you should // normally not use allocate(), and instead allocate memory using _malloc(), // initialize it with setValue(), and so forth. // @slab: An array of data, or a number. If a number, then the size of the block to allocate, // in *bytes* (note that this is sometimes confusing: the next parameter does not // affect this!) // @types: Either an array of types, one for each byte (or 0 if no type at that position), // or a single type which is used for the entire block. This only matters if there // is initial data - if @slab is a number, then this does not matter at all and is // ignored. // @allocator: How to allocate memory, see ALLOC_* 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 < stop; ptr += 4) { HEAP32[((ptr)>>2)]=0; } stop = ret + size; while (ptr < stop) { HEAP8[((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 < size) { var curr = slab[i]; if (typeof curr === 'function') { curr = Runtime.getFunctionIndex(curr); } type = singleType || types[i]; if (type === 0) { i++; continue; } assert(type, 'Must know what type to store in allocate!'); if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later setValue(ret+i, curr, type); // no need to look up size unless type changes, so cache it if (previousType !== type) { typeSize = Runtime.getNativeTypeSize(type); previousType = type; } i += typeSize; } return ret; } Module["allocate"] = allocate; // Allocate memory during any stage of startup - static memory early on, dynamic memory later, malloc when ready function getMemory(size) { if (!staticSealed) return Runtime.staticAlloc(size); if ((typeof _sbrk !== 'undefined' && !_sbrk.called) || !runtimeInitialized) return Runtime.dynamicAlloc(size); return _malloc(size); } Module["getMemory"] = getMemory; function Pointer_stringify(ptr, /* optional */ length) { if (length === 0 || !ptr) return ''; // TODO: use TextDecoder // Find the length, and check for UTF while doing so var hasUtf = 0; var t; var i = 0; while (1) { assert(ptr + i < TOTAL_MEMORY); t = HEAPU8[(((ptr)+(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; // split up into chunks, because .apply on a huge string can overflow the stack 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; // Given a pointer 'ptr' to a null-terminated ASCII-encoded string in the emscripten HEAP, returns // a copy of that string as a Javascript String object. function AsciiToString(ptr) { var str = ''; while (1) { var ch = HEAP8[((ptr++)>>0)]; if (!ch) return str; str += String.fromCharCode(ch); } } Module["AsciiToString"] = AsciiToString; // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', // null-terminated and encoded in ASCII form. The copy will require at most str.length+1 bytes of space in the HEAP. function stringToAscii(str, outPtr) { return writeAsciiToMemory(str, outPtr, false); } Module["stringToAscii"] = stringToAscii; // Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the given array that contains uint8 values, returns // a copy of that string as a Javascript String object. function UTF8ArrayToString(u8Array, idx) { var u0, u1, u2, u3, u4, u5; var str = ''; while (1) { // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description and https://www.ietf.org/rfc/rfc2279.txt and https://tools.ietf.org/html/rfc3629 u0 = u8Array[idx++]; if (!u0) return str; if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; } u1 = u8Array[idx++] & 63; if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; } u2 = u8Array[idx++] & 63; if ((u0 & 0xF0) == 0xE0) { u0 = ((u0 & 15) << 12) | (u1 << 6) | u2; } else { u3 = u8Array[idx++] & 63; if ((u0 & 0xF8) == 0xF0) { u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | u3; } else { u4 = u8Array[idx++] & 63; if ((u0 & 0xFC) == 0xF8) { 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 < 0x10000) { str += String.fromCharCode(u0); } else { var ch = u0 - 0x10000; str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF)); } } } Module["UTF8ArrayToString"] = UTF8ArrayToString; // Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the emscripten HEAP, returns // a copy of that string as a Javascript String object. function UTF8ToString(ptr) { return UTF8ArrayToString(HEAPU8,ptr); } Module["UTF8ToString"] = UTF8ToString; // Copies the given Javascript String object 'str' to the given byte array at address 'outIdx', // encoded in UTF8 form and null-terminated. The copy will require at most str.length*4+1 bytes of space in the HEAP. // Use the function lengthBytesUTF8() to compute the exact number of bytes (excluding null terminator) that this function will write. // Parameters: // str: the Javascript string to copy. // outU8Array: the array to copy to. Each index in this array is assumed to be one 8-byte element. // outIdx: The starting offset in the array to begin the copying. // maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null // terminator, i.e. if maxBytesToWrite=1, only the null terminator will be written and nothing else. // maxBytesToWrite=0 does not write any bytes to the output, not even the null terminator. // Returns the number of bytes written, EXCLUDING the null terminator. function stringToUTF8Array(str, outU8Array, outIdx, maxBytesToWrite) { if (!(maxBytesToWrite > 0)) // Parameter maxBytesToWrite is not optional. Negative values, 0, null, undefined and false each don't write out any bytes. return 0; var startIdx = outIdx; var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator. for (var i = 0; i < str.length; ++i) { // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8. // See http://unicode.org/faq/utf_bom.html#utf16-3 // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description and https://www.ietf.org/rfc/rfc2279.txt and https://tools.ietf.org/html/rfc3629 var u = str.charCodeAt(i); // possibly a lead surrogate if (u >= 0xD800 && u <= 0xDFFF) u = 0x10000 + ((u & 0x3FF) << 10) | (str.charCodeAt(++i) & 0x3FF); if (u <= 0x7F) { if (outIdx >= endIdx) break; outU8Array[outIdx++] = u; } else if (u <= 0x7FF) { if (outIdx + 1 >= endIdx) break; outU8Array[outIdx++] = 0xC0 | (u >> 6); outU8Array[outIdx++] = 0x80 | (u & 63); } else if (u <= 0xFFFF) { if (outIdx + 2 >= endIdx) break; outU8Array[outIdx++] = 0xE0 | (u >> 12); outU8Array[outIdx++] = 0x80 | ((u >> 6) & 63); outU8Array[outIdx++] = 0x80 | (u & 63); } else if (u <= 0x1FFFFF) { if (outIdx + 3 >= endIdx) break; outU8Array[outIdx++] = 0xF0 | (u >> 18); outU8Array[outIdx++] = 0x80 | ((u >> 12) & 63); outU8Array[outIdx++] = 0x80 | ((u >> 6) & 63); outU8Array[outIdx++] = 0x80 | (u & 63); } else if (u <= 0x3FFFFFF) { if (outIdx + 4 >= endIdx) break; outU8Array[outIdx++] = 0xF8 | (u >> 24); outU8Array[outIdx++] = 0x80 | ((u >> 18) & 63); outU8Array[outIdx++] = 0x80 | ((u >> 12) & 63); outU8Array[outIdx++] = 0x80 | ((u >> 6) & 63); outU8Array[outIdx++] = 0x80 | (u & 63); } else { if (outIdx + 5 >= endIdx) break; outU8Array[outIdx++] = 0xFC | (u >> 30); outU8Array[outIdx++] = 0x80 | ((u >> 24) & 63); outU8Array[outIdx++] = 0x80 | ((u >> 18) & 63); outU8Array[outIdx++] = 0x80 | ((u >> 12) & 63); outU8Array[outIdx++] = 0x80 | ((u >> 6) & 63); outU8Array[outIdx++] = 0x80 | (u & 63); } } // Null-terminate the pointer to the buffer. outU8Array[outIdx] = 0; return outIdx - startIdx; } Module["stringToUTF8Array"] = stringToUTF8Array; // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', // null-terminated and encoded in UTF8 form. The copy will require at most str.length*4+1 bytes of space in the HEAP. // Use the function lengthBytesUTF8() to compute the exact number of bytes (excluding null terminator) that this function will write. // Returns the number of bytes written, EXCLUDING the null terminator. function stringToUTF8(str, outPtr, maxBytesToWrite) { assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!'); return stringToUTF8Array(str, HEAPU8,outPtr, maxBytesToWrite); } Module["stringToUTF8"] = stringToUTF8; // Returns the number of bytes the given Javascript string takes if encoded as a UTF8 byte array, EXCLUDING the null terminator byte. function lengthBytesUTF8(str) { var len = 0; for (var i = 0; i < str.length; ++i) { // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8. // See http://unicode.org/faq/utf_bom.html#utf16-3 var u = str.charCodeAt(i); // possibly a lead surrogate if (u >= 0xD800 && u <= 0xDFFF) u = 0x10000 + ((u & 0x3FF) << 10) | (str.charCodeAt(++i) & 0x3FF); if (u <= 0x7F) { ++len; } else if (u <= 0x7FF) { len += 2; } else if (u <= 0xFFFF) { len += 3; } else if (u <= 0x1FFFFF) { len += 4; } else if (u <= 0x3FFFFFF) { len += 5; } else { len += 6; } } return len; } Module["lengthBytesUTF8"] = lengthBytesUTF8; // Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns // a copy of that string as a Javascript String object. function UTF16ToString(ptr) { var i = 0; var str = ''; while (1) { var codeUnit = HEAP16[(((ptr)+(i*2))>>1)]; if (codeUnit == 0) return str; ++i; // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through. str += String.fromCharCode(codeUnit); } } Module["UTF16ToString"] = UTF16ToString; // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', // null-terminated and encoded in UTF16 form. The copy will require at most str.length*4+2 bytes of space in the HEAP. // Use the function lengthBytesUTF16() to compute the exact number of bytes (excluding null terminator) that this function will write. // Parameters: // str: the Javascript string to copy. // outPtr: Byte address in Emscripten HEAP where to write the string to. // maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null // terminator, i.e. if maxBytesToWrite=2, only the null terminator will be written and nothing else. // maxBytesToWrite<2 does not write any bytes to the output, not even the null terminator. // Returns the number of bytes written, EXCLUDING the null terminator. function stringToUTF16(str, outPtr, maxBytesToWrite) { assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!'); // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed. if (maxBytesToWrite === undefined) { maxBytesToWrite = 0x7FFFFFFF; } if (maxBytesToWrite < 2) return 0; maxBytesToWrite -= 2; // Null terminator. var startPtr = outPtr; var numCharsToWrite = (maxBytesToWrite < str.length*2) ? (maxBytesToWrite / 2) : str.length; for (var i = 0; i < numCharsToWrite; ++i) { // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP. var codeUnit = str.charCodeAt(i); // possibly a lead surrogate HEAP16[((outPtr)>>1)]=codeUnit; outPtr += 2; } // Null-terminate the pointer to the HEAP. HEAP16[((outPtr)>>1)]=0; return outPtr - startPtr; } Module["stringToUTF16"] = stringToUTF16; // Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte. 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; // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing. // See http://unicode.org/faq/utf_bom.html#utf16-3 if (utf32 >= 0x10000) { var ch = utf32 - 0x10000; str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF)); } else { str += String.fromCharCode(utf32); } } } Module["UTF32ToString"] = UTF32ToString; // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', // null-terminated and encoded in UTF32 form. The copy will require at most str.length*4+4 bytes of space in the HEAP. // Use the function lengthBytesUTF32() to compute the exact number of bytes (excluding null terminator) that this function will write. // Parameters: // str: the Javascript string to copy. // outPtr: Byte address in Emscripten HEAP where to write the string to. // maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null // terminator, i.e. if maxBytesToWrite=4, only the null terminator will be written and nothing else. // maxBytesToWrite<4 does not write any bytes to the output, not even the null terminator. // Returns the number of bytes written, EXCLUDING the null terminator. function stringToUTF32(str, outPtr, maxBytesToWrite) { assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!'); // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed. if (maxBytesToWrite === undefined) { maxBytesToWrite = 0x7FFFFFFF; } if (maxBytesToWrite < 4) return 0; var startPtr = outPtr; var endPtr = startPtr + maxBytesToWrite - 4; for (var i = 0; i < str.length; ++i) { // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap. // See http://unicode.org/faq/utf_bom.html#utf16-3 var codeUnit = str.charCodeAt(i); // possibly a lead surrogate if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) { var trailSurrogate = str.charCodeAt(++i); codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF); } HEAP32[((outPtr)>>2)]=codeUnit; outPtr += 4; if (outPtr + 4 > endPtr) break; } // Null-terminate the pointer to the HEAP. HEAP32[((outPtr)>>2)]=0; return outPtr - startPtr; } Module["stringToUTF32"] = stringToUTF32; // Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte. function lengthBytesUTF32(str) { var len = 0; for (var i = 0; i < str.length; ++i) { // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap. // See http://unicode.org/faq/utf_bom.html#utf16-3 var codeUnit = str.charCodeAt(i); if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) ++i; // possibly a lead surrogate, so skip over the tail surrogate. 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); } // otherwise, libcxxabi failed, we can try ours which may return a partial result } catch(e) { // failure when using libcxxabi, we can try ours which may return a partial result } finally { if (buf) _free(buf); if (status) _free(status); if (ret) _free(ret); } } var i = 3; // params, etc. 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) { //return; if (x) Module.print(x); Module.print(func); var pre = ''; for (var a = 0; a < i; a++) pre += ' '; Module.print (pre + '^'); } function parseNested() { i++; if (func[i] === 'K') i++; // ignore const var parts = []; while (func[i] !== 'E') { if (func[i] === 'S') { // substitution i++; var next = func.indexOf('_', i); var num = func.substring(i, next) || 0; parts.push(subs[num] || '?'); i = next+1; continue; } if (func[i] === 'C') { // constructor parts.push(parts[parts.length-1]); i += 2; continue; } var size = parseInt(func.substr(i)); var pre = size.toString().length; if (!size || !pre) { i--; break; } // counter i++ below us var curr = func.substr(i + pre, size); parts.push(curr); subs.push(curr); i += pre + size; } i++; // skip E return parts; } function parse(rawList, limit, allowVoid) { // main parser limit = limit || Infinity; var ret = '', list = []; function flushList() { return '(' + list.join(', ') + ')'; } var name; if (func[i] === 'N') { // namespaced N-E name = parseNested().join('::'); limit--; if (limit === 0) return rawList ? [name] : name; } else { // not namespaced if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L' var size = parseInt(func.substr(i)); if (size) { var pre = size.toString().length; name = func.substr(i + pre, size); i += pre + size; } } first = false; if (func[i] === 'I') { i++; var iList = parse(true); var iRet = parse(true, 1, true); ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>'; } else { ret = name; } paramLoop: while (i < func.length && limit-- > 0) { //dump('paramLoop'); 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; // pointer case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference case 'L': { // literal i++; // skip basic type var end = func.indexOf('E', i); var size = end - i; list.push(func.substr(i, size)); i += size + 2; // size + 'EE' break; } case 'A': { // array var size = parseInt(func.substr(i)); i += size.toString().length; if (func[i] !== '_') throw '?'; i++; // skip _ 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 = []; // avoid (void) if (rawList) { if (ret) { list.push(ret + '?'); } return list; } else { return ret + flushList(); } } var parsed = func; try { // Special-case the entry point, since its name differs from other name mangling. 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; // C function 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) { // IE10+ special cases: It does have callstack info, but it is only populated if an Error object is thrown, // so try that as a special-case. 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; // Memory management 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; // static area var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk 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'] || 16777216; var totalMemory = 64*1024; while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) { if (totalMemory < 16*1024*1024) { totalMemory *= 2; } else { totalMemory += 16*1024*1024 } } if (totalMemory !== TOTAL_MEMORY) { Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be compliant with the asm.js spec (and given that TOTAL_STACK=' + TOTAL_STACK + ')'); TOTAL_MEMORY = totalMemory; } // Initialize the runtime's memory // check for full engine support (use string 'subarray' to avoid closure compiler confusion) assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']), 'JS engine does not provide full typed array support'); var buffer; buffer = new ArrayBuffer(TOTAL_MEMORY); HEAP8 = new Int8Array(buffer); HEAP16 = new Int16Array(buffer); HEAP32 = new Int32Array(buffer); HEAPU8 = new Uint8Array(buffer); HEAPU16 = new Uint16Array(buffer); HEAPU32 = new Uint32Array(buffer); HEAPF32 = new Float32Array(buffer); HEAPF64 = new Float64Array(buffer); // Endianness check (note: assumes compiler arch was little-endian) HEAP32[0] = 255; assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system'); Module['HEAP'] = HEAP; Module['buffer'] = buffer; Module['HEAP8'] = HEAP8; Module['HEAP16'] = HEAP16; Module['HEAP32'] = HEAP32; Module['HEAPU8'] = HEAPU8; Module['HEAPU16'] = HEAPU16; Module['HEAPU32'] = HEAPU32; Module['HEAPF32'] = HEAPF32; Module['HEAPF64'] = HEAPF64; function callRuntimeCallbacks(callbacks) { while(callbacks.length > 0) { 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__ = []; // functions called before the runtime is initialized var __ATINIT__ = []; // functions called during startup var __ATMAIN__ = []; // functions called when main() is to be run var __ATEXIT__ = []; // functions called during shutdown var __ATPOSTRUN__ = []; // functions called after the runtime has exited var runtimeInitialized = false; var runtimeExited = false; function preRun() { // compatibility - merge in anything from Module['preRun'] at this time 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() { // compatibility - merge in anything from Module['postRun'] at this time 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; // Tools function intArrayFromString(stringy, dontAddNull, length /* optional */) { 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; i < array.length; i++) { var chr = array[i]; if (chr > 0xFF) { assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ') at offset ' + i + ' not in 0x00-0xFF.'); chr &= 0xFF; } 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 < array.length) { var chr = array[i]; HEAP8[(((buffer)+(i))>>0)]=chr; i = i + 1; } } Module["writeStringToMemory"] = writeStringToMemory; function writeArrayToMemory(array, buffer) { for (var i = 0; i < array.length; i++) { HEAP8[((buffer++)>>0)]=array[i]; } } Module["writeArrayToMemory"] = writeArrayToMemory; function writeAsciiToMemory(str, buffer, dontAddNull) { for (var i = 0; i < str.length; ++i) { assert(str.charCodeAt(i) === str.charCodeAt(i)&0xff); HEAP8[((buffer++)>>0)]=str.charCodeAt(i); } // Null-terminate the pointer to the HEAP. 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 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts : Math.pow(2, bits) + value; } function reSign(value, bits, ignore) { if (value <= 0) { return value; } var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32 : Math.pow(2, bits-1); if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors // TODO: In i64 mode 1, resign the two parts separately and safely value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts } return value; } // check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 ) if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) { var ah = a >>> 16; var al = a & 0xffff; var bh = b >>> 16; var bl = b & 0xffff; 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; // A counter of dependencies for calling run(). If we need to // do asynchronous work before running, increment this and // decrement it. Incrementing must happen in a place like // PRE_RUN_ADDITIONS (used by emcc to add file preloading). // Note that you can add dependencies in preRun, even though // it happens right before run - run will be postponed until // the dependencies are met. var runDependencies = 0; var runDependencyWatcher = null; var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled var runDependencyTracking = {}; function getUniqueRunDependency(id) { var orig = id; while (1) { if (!runDependencyTracking[id]) return id; id = orig + Math.random(); } return id; } function addRunDependency(id) { runDependencies++; if (Module['monitorRunDependencies']) { Module['monitorRunDependencies'](runDependencies); } if (id) { assert(!runDependencyTracking[id]); runDependencyTracking[id] = 1; if (runDependencyWatcher === null && typeof setInterval !== 'undefined') { // Check for missing dependencies every few seconds runDependencyWatcher = setInterval(function() { if (ABORT) { clearInterval(runDependencyWatcher); runDependencyWatcher = null; return; } var shown = false; for (var dep in runDependencyTracking) { if (!shown) { shown = true; Module.printErr('still waiting on run dependencies:'); } Module.printErr('dependency: ' + dep); } if (shown) { Module.printErr('(end of list)'); } }, 10000); } } else { Module.printErr('warning: run dependency added without ID'); } } Module["addRunDependency"] = addRunDependency; function removeRunDependency(id) { runDependencies--; if (Module['monitorRunDependencies']) { Module['monitorRunDependencies'](runDependencies); } if (id) { assert(runDependencyTracking[id]); delete runDependencyTracking[id]; } else { Module.printErr('warning: run dependency removed without ID'); } if (runDependencies == 0) { if (runDependencyWatcher !== null) { clearInterval(runDependencyWatcher); runDependencyWatcher = null; } if (dependenciesFulfilled) { var callback = dependenciesFulfilled; dependenciesFulfilled = null; callback(); // can add another dependenciesFulfilled } } } Module["removeRunDependency"] = removeRunDependency; Module["preloadedImages"] = {}; // maps url to image data Module["preloadedAudios"] = {}; // maps url to audio data var memoryInitializer = null; // === Body === var ASM_CONSTS = [function($0, $1, $2) { { window.fo_canvas = document.createElement('canvas'); document.body.style.margin = '0px'; window.fo_canvas.style.cursor = 'none'; window.fo_canvas.width = $0; window.fo_canvas.height = $1; window.fo_buf_address = $2; window.fo_buf_size = 4 * $0 * $1; document.body.appendChild(window.fo_canvas); window.fo_context = window.fo_canvas.getContext('2d'); window.fo_canvas_data = window.fo_context.getImageData(0, 0, $0, $1); setInterval(function() { window.fo_canvas_data.data.set( Module.HEAPU8.subarray( window.fo_buf_address, window.fo_buf_address + window.fo_buf_size ) ); window.fo_context.putImageData(window.fo_canvas_data, 0, 0); }, 17); } }, function($0) { { return window.fo_mouse_x; } }, function($0) { { return window.fo_mouse_y; } }, function($0) { { return window.fo_button_status; } }, function() { window.fo_button_status = 0; window.fo_mouse_x = 0; window.fo_mouse_y = 0; window.fo_canvas.onmousemove = function(e) { window.fo_mouse_x = e.clientX; window.fo_mouse_y = e.clientY; Module.ccall('fake_os_doMouseCallback'); }; window.fo_canvas.onmousedown = function(e) { window.fo_button_status = 1; Module.ccall('fake_os_doMouseCallback'); }; window.fo_canvas.onmouseup = function(e) { window.fo_button_status = 0; Module.ccall('fake_os_doMouseCallback'); }; }]; function _emscripten_asm_const_0(code) { return ASM_CONSTS[code](); } function _emscripten_asm_const_1(code, a0) { return ASM_CONSTS[code](a0); } function _emscripten_asm_const_3(code, a0, a1, a2) { return ASM_CONSTS[code](a0, a1, a2); } STATIC_BASE = 8; STATICTOP = STATIC_BASE + 4128; /* global initializers */ __ATINIT__.push(); /* memory initializer */ allocate([0,0,0,0,0,0,0,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,255,0,0,0,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,255,255,255,255,255,0,0,0,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,255,255,255,255,255,255,255,255,255,0,0,0,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,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,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,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,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,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,255,0,0,0,0,0,0,0,0,0,0,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,0,0,0,255,0,0,0,0,0,0,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,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,0,0,0,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,255,255,255,255,255,255,255,255,255,0,0,0,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,255,255,255,255,255,255,255,255,255,0,0,0,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,255,255,255,255,255,255,255,255,255,0,0,0,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,255,255,255,255,255,0,0,0,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,255,0,0,0,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,123,32,119,105,110,100,111,119,46,102,111,95,99,97,110,118,97,115,32,61,32,100,111,99,117,109,101,110,116,46,99,114,101,97,116,101,69,108,101,109,101,110,116,40,39,99,97,110,118,97,115,39,41,59,32,100,111,99,117,109,101,110,116,46,98,111,100,121,46,115,116,121,108,101,46,109,97,114,103,105,110,32,61,32,39,48,112,120,39,59,32,119,105,110,100,111,119,46,102,111,95,99,97,110,118,97,115,46,115,116,121,108,101,46,99,117,114,115,111,114,32,61,32,39,110,111,110,101,39,59,32,119,105,110,100,111,119,46,102,111,95,99,97,110,118,97,115,46,119,105,100,116,104,32,61,32,36,48,59,32,119,105,110,100,111,119,46,102,111,95,99,97,110,118,97,115,46,104,101,105,103,104,116,32,61,32,36,49,59,32,119,105,110,100,111,119,46,102,111,95,98,117,102,95,97,100,100,114,101,115,115,32,61,32,36,50,59,32,119,105,110,100,111,119,46,102,111,95,98,117,102,95,115,105,122,101,32,61,32,52,32,42,32,36,48,32,42,32,36,49,59,32,100,111,99,117,109,101,110,116,46,98,111,100,121,46,97,112,112,101,110,100,67,104,105,108,100,40,119,105,110,100,111,119,46,102,111,95,99,97,110,118,97,115,41,59,32,119,105,110,100,111,119,46,102,111,95,99,111,110,116,101,120,116,32,61,32,119,105,110,100,111,119,46,102,111,95,99,97,110,118,97,115,46,103,101,116,67,111,110,116,101,120,116,40,39,50,100,39,41,59,32,119,105,110,100,111,119,46,102,111,95,99,97,110,118,97,115,95,100,97,116,97,32,61,32,119,105,110,100,111,119,46,102,111,95,99,111,110,116,101,120,116,46,103,101,116,73,109,97,103,101,68,97,116,97,40,48,44,32,48,44,32,36,48,44,32,36,49,41,59,32,115,101,116,73,110,116,101,114,118,97,108,40,102,117,110,99,116,105,111,110,40,41,32,123,32,119,105,110,100,111,119,46,102,111,95,99,97,110,118,97,115,95,100,97,116,97,46,100,97,116,97,46,115,101,116,40,32,77,111,100,117,108,101,46,72,69,65,80,85,56,46,115,117,98,97,114,114,97,121,40,32,119,105,110,100,111,119,46,102,111,95,98,117,102,95,97,100,100,114,101,115,115,44,32,119,105,110,100,111,119,46,102,111,95,98,117,102,95,97,100,100,114,101,115,115,32,43,32,119,105,110,100,111,119,46,102,111,95,98,117,102,95,115,105,122,101,32,41,32,41,59,32,119,105,110,100,111,119,46,102,111,95,99,111,110,116,101,120,116,46,112,117,116,73,109,97,103,101,68,97,116,97,40,119,105,110,100,111,119,46,102,111,95,99,97,110,118,97,115,95,100,97,116,97,44,32,48,44,32,48,41,59,32,125,44,32,49,55,41,59,32,125,0,123,32,114,101,116,117,114,110,32,119,105,110,100,111,119,46,102,111,95,109,111,117,115,101,95,120,59,32,125,0,123,32,114,101,116,117,114,110,32,119,105,110,100,111,119,46,102,111,95,109,111,117,115,101,95,121,59,32,125,0,123,32,114,101,116,117,114,110,32,119,105,110,100,111,119,46,102,111,95,98,117,116,116,111,110,95,115,116,97,116,117,115,59,32,125,0,119,105,110,100,111,119,46,102,111,95,98,117,116,116,111,110,95,115,116,97,116,117,115,32,61,32,48,59,32,119,105,110,100,111,119,46,102,111,95,109,111,117,115,101,95,120,32,61,32,48,59,32,119,105,110,100,111,119,46,102,111,95,109,111,117,115,101,95,121,32,61,32,48,59,32,119,105,110,100,111,119,46,102,111,95,99,97,110,118,97,115,46,111,110,109,111,117,115,101,109,111,118,101,32,61,32,102,117,110,99,116,105,111,110,40,101,41,32,123,32,119,105,110,100,111,119,46,102,111,95,109,111,117,115,101,95,120,32,61,32,101,46,99,108,105,101,110,116,88,59,32,119,105,110,100,111,119,46,102,111,95,109,111,117,115,101,95,121,32,61,32,101,46,99,108,105,101,110,116,89,59,32,77,111,100,117,108,101,46,99,99,97,108,108,40,39,102,97,107,101,95,111,115,95,100,111,77,111,117,115,101,67,97,108,108,98,97,99,107,39,41,59,32,125,59,32,119,105,110,100,111,119,46,102,111,95,99,97,110,118,97,115,46,111,110,109,111,117,115,101,100,111,119,110,32,61,32,102,117,110,99,116,105,111,110,40,101,41,32,123,32,119,105,110,100,111,119,46,102,111,95,98,117,116,116,111,110,95,115,116,97,116,117,115,32,61,32,49,59,32,77,111,100,117,108,101,46,99,99,97,108,108,40,39,102,97,107,101,95,111,115,95,100,111,77,111,117,115,101,67,97,108,108,98,97,99,107,39,41,59,32,125,59,32,119,105,110,100,111,119,46,102,111,95,99,97,110,118,97,115,46,111,110,109,111,117,115,101,117,112,32,61,32,102,117,110,99,116,105,111,110,40,101,41,32,123,32,119,105,110,100,111,119,46,102,111,95,98,117,116,116,111,110,95,115,116,97,116,117,115,32,61,32,48,59,32,77,111,100,117,108,101,46,99,99,97,108,108,40,39,102,97,107,101,95,111,115,95,100,111,77,111,117,115,101,67,97,108,108,98,97,99,107,39,41,59,32,125,59,0,48,0,49,0,50,0,51,0,52,0,53,0,54,0,55,0,56,0,57,0,67,97,108,99,117,108,97,116,111,114,0,43,0,45,0,42,0,67,0,61,0,47,0,0,0,0,0,0,0,0,0,0,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,36,0,0,0,0,16,8,32,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,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,96,0,0,0,0,0,0,0,0,0,0,0,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,36,0,8,0,0,16,16,16,84,0,0,0,0,4,56,8,60,126,4,62,60,126,24,60,0,0,0,0,0,24,0,24,112,60,120,126,126,60,66,124,126,68,64,65,66,60,124,60,124,60,127,66,66,65,66,68,126,28,64,56,16,0,48,0,64,0,2,0,0,0,64,0,0,32,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,8,16,0,0,0,0,0,0,0,0,0,0,0,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,36,18,28,64,24,16,16,16,56,0,0,0,0,4,76,24,66,2,12,32,66,2,36,66,16,0,0,0,0,36,56,36,72,66,68,64,64,66,66,16,4,68,64,99,98,66,66,66,66,66,8,66,66,65,66,68,2,16,64,8,40,0,16,0,64,0,2,0,12,0,64,0,0,32,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,8,16,0,0,0,0,0,0,0,0,0,0,0,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,72,18,42,162,32,16,32,8,40,16,0,0,0,8,76,40,66,4,20,64,64,4,36,66,16,16,2,0,64,66,68,66,68,64,66,64,64,64,66,16,4,72,64,99,98,66,66,66,66,64,8,66,66,65,36,68,2,16,32,8,68,0,0,0,64,0,2,0,18,0,64,16,4,32,16,0,0,0,0,0,0,0,16,0,0,0,0,0,0,8,8,16,0,0,0,0,0,0,0,0,0,0,0,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,127,40,164,16,0,32,8,40,16,0,0,0,8,76,8,2,24,36,64,64,8,24,66,0,0,12,126,48,2,130,66,68,64,66,64,64,64,66,16,4,80,64,85,82,66,66,66,66,32,8,66,66,65,36,68,4,16,32,8,0,0,0,56,64,0,2,0,16,30,64,0,0,32,16,84,44,60,92,60,44,28,62,36,34,68,66,36,62,16,8,8,0,0,0,0,0,0,0,0,0,0,0,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,36,24,72,32,0,32,8,0,124,0,126,0,16,84,8,2,4,68,124,92,8,36,62,0,0,48,0,12,4,146,66,120,64,66,124,124,64,66,16,4,96,64,85,82,66,124,66,124,24,8,66,66,73,24,40,8,16,16,8,0,0,0,4,92,60,58,60,16,34,64,0,4,34,16,42,18,66,34,68,18,34,16,36,34,68,34,36,2,32,8,4,50,0,0,0,0,0,0,0,0,0,0,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,36,12,16,82,0,32,8,0,16,0,0,0,16,84,8,4,2,68,2,98,16,66,2,0,0,64,0,2,8,170,126,68,64,66,64,64,78,126,16,4,80,64,73,74,66,64,66,80,4,8,66,66,73,24,16,16,16,16,8,0,0,0,60,98,66,70,66,60,34,92,16,4,44,16,42,18,66,34,68,16,32,16,36,34,84,36,36,4,16,8,8,76,0,0,0,0,0,0,0,0,0,0,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,254,10,34,74,0,32,8,0,16,0,0,0,32,84,8,8,2,126,2,66,16,66,2,16,16,48,126,12,16,170,66,66,64,66,64,64,66,66,16,68,72,64,73,74,66,64,66,76,2,8,66,36,73,36,16,32,16,8,8,0,0,0,68,66,64,66,126,16,30,98,16,4,48,16,42,18,66,50,60,16,28,16,36,34,84,24,28,8,8,8,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,72,10,69,68,0,32,8,0,0,0,0,0,32,100,8,16,2,4,66,66,16,66,2,16,16,12,0,48,16,148,66,66,64,66,64,64,66,66,16,68,68,64,65,70,66,64,74,66,66,8,66,36,73,36,16,64,16,8,8,0,0,0,68,66,64,66,64,16,2,66,16,4,40,16,42,18,66,44,4,16,2,16,36,34,84,36,4,16,8,8,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,72,42,5,58,0,16,16,0,0,32,0,0,64,100,8,32,68,4,66,66,16,66,4,0,32,2,0,64,0,64,66,66,66,68,64,64,66,66,16,68,66,64,65,70,66,64,68,66,66,8,66,36,73,66,16,64,16,4,8,0,0,0,68,98,66,70,66,16,34,66,16,36,36,16,42,18,66,32,4,16,34,16,36,20,84,68,4,32,8,8,16,0,0,0,0,0,0,0,0,0,0,0,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,28,2,0,0,16,16,0,0,32,0,0,64,56,8,126,56,4,60,60,16,60,56,0,0,0,0,0,0,56,66,124,60,120,126,64,60,66,124,56,66,126,65,66,60,64,58,66,60,8,60,24,54,66,16,126,28,4,56,0,127,0,58,92,60,58,60,16,28,66,8,24,34,8,42,18,60,32,2,16,28,14,26,8,42,66,56,62,8,8,16,0,0,0,0,0,0,0,0,0,0,0,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,8,0,0,0,8,32,0,0,64,0,16,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,96,0,0,87,105,110,100,111,119,105,110,103,32,83,121,115,116,101,109,115,32,98,121,32,69,120,97,109,112,108,101,0,78,101,119,32,67,97,108,99,117,108,97,116,111,114,0], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE); /* no memory initializer */ var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8); assert(tempDoublePtr % 8 == 0); function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much 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]; } // {{PRE_LIBRARY}} function _sbrk(bytes) { // Implement a Linux-like 'memory area' for our 'process'. // Changes the size of the memory area by |bytes|; returns the // address of the previous top ('break') of the memory area // We control the "dynamic" memory - DYNAMIC_BASE to DYNAMICTOP var self = _sbrk; if (!self.called) { DYNAMICTOP = alignMemoryPage(DYNAMICTOP); // make sure we start out aligned self.called = true; assert(Runtime.dynamicAlloc); self.alloc = Runtime.dynamicAlloc; Runtime.dynamicAlloc = function() { abort('cannot dynamically allocate, sbrk now has control') }; } var ret = DYNAMICTOP; if (bytes != 0) { var success = self.alloc(bytes); if (!success) return -1 >>> 0; // sbrk failure code } return ret; // Previous break location. } function ___setErrNo(value) { if (Module['___errno_location']) HEAP32[((Module['___errno_location']())>>2)]=value; else Module.printErr('failed to set errno from JS'); 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) { // long sysconf(int name); // http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html 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 1000; 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["_memset"] = _memset; var _emscripten_asm_const=true; var _emscripten_asm_const_int=true; function _abort() { Module['abort'](); } var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"}; var TTY={ttys:[],init:function () { // https://github.com/kripken/emscripten/pull/1555 // if (ENVIRONMENT_IS_NODE) { // // currently, FS.init does not distinguish if process.stdin is a file or TTY // // device, it always assumes it's a TTY device. because of this, we're forcing // // process.stdin to UTF8 encoding to at least make stdin reading compatible // // with text files until FS.init can be refactored. // process['stdin']['setEncoding']('utf8'); // } },shutdown:function () { // https://github.com/kripken/emscripten/pull/1555 // if (ENVIRONMENT_IS_NODE) { // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)? // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists? // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call // process['stdin']['pause'](); // } },register:function (dev, ops) { TTY.ttys[dev] = { input: [], output: [], ops: ops }; FS.registerDevice(dev, TTY.stream_ops); },stream_ops:{open:function (stream) { var tty = TTY.ttys[stream.node.rdev]; if (!tty) { throw new FS.ErrnoError(ERRNO_CODES.ENODEV); } stream.tty = tty; stream.seekable = false; },close:function (stream) { // flush any pending line data stream.tty.ops.flush(stream.tty); },flush:function (stream) { stream.tty.ops.flush(stream.tty); },read:function (stream, buffer, offset, length, pos /* ignored */) { if (!stream.tty || !stream.tty.ops.get_char) { throw new FS.ErrnoError(ERRNO_CODES.ENXIO); } var bytesRead = 0; for (var i = 0; i < length; i++) { var result; try { result = stream.tty.ops.get_char(stream.tty); } catch (e) { throw new FS.ErrnoError(ERRNO_CODES.EIO); } if (result === undefined && bytesRead === 0) { throw new FS.ErrnoError(ERRNO_CODES.EAGAIN); } if (result === null || result === undefined) break; bytesRead++; buffer[offset+i] = result; } if (bytesRead) { stream.node.timestamp = Date.now(); } return bytesRead; },write:function (stream, buffer, offset, length, pos) { if (!stream.tty || !stream.tty.ops.put_char) { throw new FS.ErrnoError(ERRNO_CODES.ENXIO); } for (var i = 0; i < length; i++) { try { stream.tty.ops.put_char(stream.tty, buffer[offset+i]); } catch (e) { throw new FS.ErrnoError(ERRNO_CODES.EIO); } } if (length) { stream.node.timestamp = Date.now(); } return i; }},default_tty_ops:{get_char:function (tty) { if (!tty.input.length) { var result = null; if (ENVIRONMENT_IS_NODE) { // we will read data by chunks of BUFSIZE var BUFSIZE = 256; var buf = new Buffer(BUFSIZE); var bytesRead = 0; var fd = process.stdin.fd; // Linux and Mac cannot use process.stdin.fd (which isn't set up as sync) var usingDevice = false; try { fd = fs.openSync('/dev/stdin', 'r'); usingDevice = true; } catch (e) {} bytesRead = fs.readSync(fd, buf, 0, BUFSIZE, null); if (usingDevice) { fs.closeSync(fd); } if (bytesRead > 0) { result = buf.slice(0, bytesRead).toString('utf-8'); } else { result = null; } } else if (typeof window != 'undefined' && typeof window.prompt == 'function') { // Browser. result = window.prompt('Input: '); // returns null on cancel if (result !== null) { result += '\n'; } } else if (typeof readline == 'function') { // Command line. 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); // val == 0 would cut text output off in the middle. } },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 /* 0777 */, 0); },createNode:function (parent, name, mode, dev) { if (FS.isBlkdev(mode) || FS.isFIFO(mode)) { // no supported 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; // The actual number of bytes used in the typed array, as opposed to contents.buffer.byteLength which gives the whole capacity. // When the byte data of the file is populated, this will point to either a typed array, or a normal JS array. Typed arrays are preferred // for performance, and used by default. However, typed arrays are not resizable like normal JS arrays are, so there is a small disk size // penalty involved for appending file writes that continuously grow a file similar to std::vector capacity vs used -scheme. 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(); // add the new node to the parent if (parent) { parent.contents[name] = node; } return node; },getFileDataAsRegularArray:function (node) { if (node.contents && node.contents.subarray) { var arr = []; for (var i = 0; i < node.usedBytes; ++i) arr.push(node.contents[i]); return arr; // Returns a copy of the original data. } return node.contents; // No-op, the file contents are already in a JS array. Return as-is. },getFileDataAsTypedArray:function (node) { if (!node.contents) return new Uint8Array; if (node.contents.subarray) return node.contents.subarray(0, node.usedBytes); // Make sure to not return excess unused bytes. return new Uint8Array(node.contents); },expandFileStorage:function (node, newCapacity) { // If we are asked to expand the size of a file that already exists, revert to using a standard JS array to store the file // instead of a typed array. This makes resizing the array more flexible because we can just .push() elements at the back to // increase the size. if (node.contents && node.contents.subarray && newCapacity > node.contents.length) { node.contents = MEMFS.getFileDataAsRegularArray(node); node.usedBytes = node.contents.length; // We might be writing to a lazy-loaded file which had overridden this property, so force-reset it. } if (!node.contents || node.contents.subarray) { // Keep using a typed array if creating a new storage, or if old one was a typed array as well. var prevCapacity = node.contents ? node.contents.buffer.byteLength : 0; if (prevCapacity >= newCapacity) return; // No need to expand, the storage was already large enough. // Don't expand strictly to the given requested limit if it's only a very small increase, but instead geometrically grow capacity. // For small filesizes (<1MB), perform size*2 geometric increase, but for large sizes, do a much more conservative size*1.125 increase to // avoid overshooting the allocation cap by a very large margin. var CAPACITY_DOUBLING_MAX = 1024 * 1024; newCapacity = Math.max(newCapacity, (prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2.0 : 1.125)) | 0); if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256); // At minimum allocate 256b for each file when expanding. var oldContents = node.contents; node.contents = new Uint8Array(newCapacity); // Allocate new storage. if (node.usedBytes > 0) node.contents.set(oldContents.subarray(0, node.usedBytes), 0); // Copy old data over to the new storage. return; } // Not using a typed array to back the file storage. Use a standard JS array instead. if (!node.contents && newCapacity > 0) node.contents = []; while (node.contents.length < newCapacity) node.contents.push(0); },resizeFileStorage:function (node, newSize) { if (node.usedBytes == newSize) return; if (newSize == 0) { node.contents = null; // Fully decommit when requesting a resize to zero. node.usedBytes = 0; return; } if (!node.contents || node.contents.subarray) { // Resize a typed array if that is being used as the backing store. var oldContents = node.contents; node.contents = new Uint8Array(new ArrayBuffer(newSize)); // Allocate new storage. if (oldContents) { node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes))); // Copy old data over to the new storage. } node.usedBytes = newSize; return; } // Backing with a JS array. if (!node.contents) node.contents = []; if (node.contents.length > newSize) node.contents.length = newSize; else while (node.contents.length < newSize) node.contents.push(0); node.usedBytes = newSize; },node_ops:{getattr:function (node) { var attr = {}; // device numbers reuse inode numbers. attr.dev = FS.isChrdev(node.mode) ? node.id : 1; attr.ino = node.id; attr.mode = node.mode; attr.nlink = 1; attr.uid = 0; attr.gid = 0; attr.rdev = node.rdev; if (FS.isDir(node.mode)) { attr.size = 4096; } else if (FS.isFile(node.mode)) { attr.size = node.usedBytes; } else if (FS.isLink(node.mode)) { attr.size = node.link.length; } else { attr.size = 0; } attr.atime = new Date(node.timestamp); attr.mtime = new Date(node.timestamp); attr.ctime = new Date(node.timestamp); // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize), // but this is not required by the standard. attr.blksize = 4096; attr.blocks = Math.ceil(attr.size / attr.blksize); return attr; },setattr:function (node, attr) { if (attr.mode !== undefined) { node.mode = attr.mode; } if (attr.timestamp !== undefined) { node.timestamp = attr.timestamp; } if (attr.size !== undefined) { MEMFS.resizeFileStorage(node, attr.size); } },lookup:function (parent, name) { throw FS.genericErrors[ERRNO_CODES.ENOENT]; },mknod:function (parent, name, mode, dev) { return MEMFS.createNode(parent, name, mode, dev); },rename:function (old_node, new_dir, new_name) { // if we're overwriting a directory at new_name, make sure it's empty. if (FS.isDir(old_node.mode)) { var new_node; try { new_node = FS.lookupNode(new_dir, new_name); } catch (e) { } if (new_node) { for (var i in new_node.contents) { throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY); } } } // do the internal rewiring delete old_node.parent.contents[old_node.name]; old_node.name = new_name; new_dir.contents[new_name] = old_node; old_node.parent = new_dir; },unlink:function (parent, name) { delete parent.contents[name]; },rmdir:function (parent, name) { var node = FS.lookupNode(parent, name); for (var i in node.contents) { throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY); } delete parent.contents[name]; },readdir:function (node) { var entries = ['.', '..'] for (var key in node.contents) { if (!node.contents.hasOwnProperty(key)) { continue; } entries.push(key); } return entries; },symlink:function (parent, newname, oldpath) { var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0); node.link = oldpath; return node; },readlink:function (node) { if (!FS.isLink(node.mode)) { throw new FS.ErrnoError(ERRNO_CODES.EINVAL); } return node.link; }},stream_ops:{read:function (stream, buffer, offset, length, position) { var contents = stream.node.contents; if (position >= stream.node.usedBytes) return 0; var size = Math.min(stream.node.usedBytes - position, length); assert(size >= 0); if (size > 8 && contents.subarray) { // non-trivial, and typed array buffer.set(contents.subarray(position, position + size), offset); } else { for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i]; } return size; },write:function (stream, buffer, offset, length, position, canOwn) { if (!length) return 0; var node = stream.node; node.timestamp = Date.now(); if (buffer.subarray && (!node.contents || node.contents.subarray)) { // This write is from a typed array to a typed array? if (canOwn) { // Can we just reuse the buffer we are given? assert(position === 0, 'canOwn must imply no weird position inside the file'); node.contents = buffer.subarray(offset, offset + length); node.usedBytes = length; return length; } else if (node.usedBytes === 0 && position === 0) { // If this is a simple first write to an empty file, do a fast set since we don't need to care about old data. node.contents = new Uint8Array(buffer.subarray(offset, offset + length)); node.usedBytes = length; return length; } else if (position + length <= node.usedBytes) { // Writing to an already allocated and used subrange of the file? node.contents.set(buffer.subarray(offset, offset + length), position); return length; } } // Appending to an existing file and we need to reallocate, or source data did not come as a typed array. MEMFS.expandFileStorage(node, position+length); if (node.contents.subarray && buffer.subarray) node.contents.set(buffer.subarray(offset, offset + length), position); // Use typed array write if available. else { for (var i = 0; i < length; i++) { node.contents[position + i] = buffer[offset + i]; // Or fall back to manual write if not. } } node.usedBytes = Math.max(node.usedBytes, position+length); return length; },llseek:function (stream, offset, whence) { var position = offset; if (whence === 1) { // SEEK_CUR. position += stream.position; } else if (whence === 2) { // SEEK_END. if (FS.isFile(stream.node.mode)) { position += stream.node.usedBytes; } } if (position < 0) { throw new FS.ErrnoError(ERRNO_CODES.EINVAL); } return position; },allocate:function (stream, offset, length) { MEMFS.expandFileStorage(stream.node, offset + length); stream.node.usedBytes = Math.max(stream.node.usedBytes, offset + length); },mmap:function (stream, buffer, offset, length, position, prot, flags) { if (!FS.isFile(stream.node.mode)) { throw new FS.ErrnoError(ERRNO_CODES.ENODEV); } var ptr; var allocated; var contents = stream.node.contents; // Only make a new copy when MAP_PRIVATE is specified. if ( !(flags & 2) && (contents.buffer === buffer || contents.buffer === buffer.buffer) ) { // We can't emulate MAP_SHARED when the file is not backed by the buffer // we're mapping to (e.g. the HEAP buffer). allocated = false; ptr = contents.byteOffset; } else { // Try to avoid unnecessary slices. if (position > 0 || position + length < stream.node.usedBytes) { if (contents.subarray) { contents = contents.subarray(position, position + length); } else { contents = Array.prototype.slice.call(contents, position, position + length); } } allocated = true; ptr = _malloc(length); if (!ptr) { throw new FS.ErrnoError(ERRNO_CODES.ENOMEM); } buffer.set(contents, ptr); } return { ptr: ptr, allocated: allocated }; },msync:function (stream, buffer, offset, length, mmapFlags) { if (!FS.isFile(stream.node.mode)) { throw new FS.ErrnoError(ERRNO_CODES.ENODEV); } if (mmapFlags & 2) { // MAP_PRIVATE calls need not to be synced back to underlying fs return 0; } var bytesWritten = MEMFS.stream_ops.write(stream, buffer, 0, length, offset, false); // should we check if bytesWritten and length are the same? return 0; }}}; var IDBFS={dbs:{},indexedDB:function () { if (typeof indexedDB !== 'undefined') return indexedDB; var ret = null; if (typeof window === 'object') ret = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB; assert(ret, 'IDBFS used, but indexedDB not supported'); return ret; },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) { // reuse all of the core MEMFS functionality return MEMFS.mount.apply(null, arguments); },syncfs:function (mount, populate, callback) { IDBFS.getLocalSet(mount, function(err, local) { if (err) return callback(err); IDBFS.getRemoteSet(mount, function(err, remote) { if (err) return callback(err); var src = populate ? remote : local; var dst = populate ? local : remote; IDBFS.reconcile(src, dst, callback); }); }); },getDB:function (name, callback) { // check the cache first var db = IDBFS.dbs[name]; if (db) { return callback(null, db); } var req; try { req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION); } catch (e) { return callback(e); } req.onupgradeneeded = function(e) { var db = e.target.result; var transaction = e.target.transaction; var fileStore; if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) { fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME); } else { fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME); } if (!fileStore.indexNames.contains('timestamp')) { fileStore.createIndex('timestamp', 'timestamp', { unique: false }); } }; req.onsuccess = function() { db = req.result; // add to the cache IDBFS.dbs[name] = db; callback(null, db); }; req.onerror = function(e) { callback(this.error); e.preventDefault(); }; },getLocalSet:function (mount, callback) { var entries = {}; function isRealDir(p) { return p !== '.' && p !== '..'; }; function toAbsolute(root) { return function(p) { return PATH.join2(root, p); } }; var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint)); while (check.length) { var path = check.pop(); var stat; try { stat = FS.stat(path); } catch (e) { return callback(e); } if (FS.isDir(stat.mode)) { check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path))); } entries[path] = { timestamp: stat.mtime }; } return callback(null, { type: 'local', entries: entries }); },getRemoteSet:function (mount, callback) { var entries = {}; IDBFS.getDB(mount.mountpoint, function(err, db) { if (err) return callback(err); var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly'); transaction.onerror = function(e) { callback(this.error); e.preventDefault(); }; var store = transaction.objectStore(IDBFS.DB_STORE_NAME); var index = store.index('timestamp'); index.openKeyCursor().onsuccess = function(event) { var cursor = event.target.result; if (!cursor) { return callback(null, { type: 'remote', db: db, entries: entries }); } entries[cursor.primaryKey] = { timestamp: cursor.key }; cursor.continue(); }; }); },loadLocalEntry:function (path, callback) { var stat, node; try { var lookup = FS.lookupPath(path); node = lookup.node; stat = FS.stat(path); } catch (e) { return callback(e); } if (FS.isDir(stat.mode)) { return callback(null, { timestamp: stat.mtime, mode: stat.mode }); } else if (FS.isFile(stat.mode)) { // Performance consideration: storing a normal JavaScript array to a IndexedDB is much slower than storing a typed array. // Therefore always convert the file contents to a typed array first before writing the data to IndexedDB. node.contents = MEMFS.getFileDataAsTypedArray(node); return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents }); } else { return callback(new Error('node type not supported')); } },storeLocalEntry:function (path, entry, callback) { try { if (FS.isDir(entry.mode)) { FS.mkdir(path, entry.mode); } else if (FS.isFile(entry.mode)) { FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true }); } else { return callback(new Error('node type not supported')); } FS.chmod(path, entry.mode); FS.utime(path, entry.timestamp, entry.timestamp); } catch (e) { return callback(e); } callback(null); },removeLocalEntry:function (path, callback) { try { var lookup = FS.lookupPath(path); var stat = FS.stat(path); if (FS.isDir(stat.mode)) { FS.rmdir(path); } else if (FS.isFile(stat.mode)) { FS.unlink(path); } } catch (e) { return callback(e); } callback(null); },loadRemoteEntry:function (store, path, callback) { var req = store.get(path); req.onsuccess = function(event) { callback(null, event.target.result); }; req.onerror = function(e) { callback(this.error); e.preventDefault(); }; },storeRemoteEntry:function (store, path, entry, callback) { var req = store.put(entry, path); req.onsuccess = function() { callback(null); }; req.onerror = function(e) { callback(this.error); e.preventDefault(); }; },removeRemoteEntry:function (store, path, callback) { var req = store.delete(path); req.onsuccess = function() { callback(null); }; req.onerror = function(e) { callback(this.error); e.preventDefault(); }; },reconcile:function (src, dst, callback) { var total = 0; var create = []; Object.keys(src.entries).forEach(function (key) { var e = src.entries[key]; var e2 = dst.entries[key]; if (!e2 || e.timestamp > e2.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(); }; // sort paths in ascending order so directory entries are created // before the files inside them 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); }); } }); // sort paths in descending order so files are deleted before their // parent directories 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) { // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so // propagate write bits to execute bits. 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 &= ~0100000 /*O_LARGEFILE*/; // Ignore this flag from musl, otherwise node.js fails to open the file. 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]); } // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096. // See http://support.microsoft.com/kb/140365 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); // update the common node structure mode as well 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); // create the backing node for this in the fs root as well 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; // node errors on 0 length reads // FIXME this is terrible. 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 < res; i++) { buffer[offset + i] = nbuffer[i]; } } return res; },write:function (stream, buffer, offset, length, position) { // FIXME this is terrible. var nbuffer = new Buffer(buffer.subarray(offset, offset + length)); var res; try { res = fs.writeSync(stream.nfd, nbuffer, 0, length, position); } catch (e) { throw new FS.ErrnoError(ERRNO_CODES[e.code]); } return res; },llseek:function (stream, offset, whence) { var position = offset; if (whence === 1) { // SEEK_CUR. position += stream.position; } else if (whence === 2) { // SEEK_END. if (FS.isFile(stream.node.mode)) { try { var stat = fs.fstatSync(stream.nfd); position += stat.size; } catch (e) { throw new FS.ErrnoError(ERRNO_CODES[e.code]); } } } if (position < 0) { throw new FS.ErrnoError(ERRNO_CODES.EINVAL); } return position; }}}; var WORKERFS={DIR_MODE:16895,FILE_MODE:33279,reader:null,mount:function (mount) { assert(ENVIRONMENT_IS_WORKER); if (!WORKERFS.reader) WORKERFS.reader = new FileReaderSync(); var root = WORKERFS.createNode(null, '/', WORKERFS.DIR_MODE, 0); var createdParents = {}; function ensureParent(path) { // return the parent node, creating subdirs as necessary var parts = path.split('/'); var parent = root; for (var i = 0; i < parts.length-1; i++) { var curr = parts.slice(0, i+1).join('/'); if (!createdParents[curr]) { createdParents[curr] = WORKERFS.createNode(parent, curr, WORKERFS.DIR_MODE, 0); } parent = createdParents[curr]; } return parent; } function base(path) { var parts = path.split('/'); return parts[parts.length-1]; } // We also accept FileList here, by using Array.prototype Array.prototype.forEach.call(mount.opts["files"] || [], function(file) { WORKERFS.createNode(ensureParent(file.name), base(file.name), WORKERFS.FILE_MODE, 0, file, file.lastModifiedDate); }); (mount.opts["blobs"] || []).forEach(function(obj) { WORKERFS.createNode(ensureParent(obj["name"]), base(obj["name"]), WORKERFS.FILE_MODE, 0, obj["data"]); }); (mount.opts["packages"] || []).forEach(function(pack) { pack['metadata'].files.forEach(function(file) { var name = file.filename.substr(1); // remove initial slash WORKERFS.createNode(ensureParent(name), base(name), WORKERFS.FILE_MODE, 0, pack['blob'].slice(file.start, file.end)); }); }); return root; },createNode:function (parent, name, mode, dev, contents, mtime) { var node = FS.createNode(parent, name, mode); node.mode = mode; node.node_ops = WORKERFS.node_ops; node.stream_ops = WORKERFS.stream_ops; node.timestamp = (mtime || new Date).getTime(); assert(WORKERFS.FILE_MODE !== WORKERFS.DIR_MODE); if (mode === WORKERFS.FILE_MODE) { node.size = contents.size; node.contents = contents; } else { node.size = 4096; node.contents = {}; } if (parent) { parent.contents[name] = node; } return node; },node_ops:{getattr:function (node) { return { dev: 1, ino: undefined, mode: node.mode, nlink: 1, uid: 0, gid: 0, rdev: undefined, size: node.size, atime: new Date(node.timestamp), mtime: new Date(node.timestamp), ctime: new Date(node.timestamp), blksize: 4096, blocks: Math.ceil(node.size / 4096), }; },setattr:function (node, attr) { if (attr.mode !== undefined) { node.mode = attr.mode; } if (attr.timestamp !== undefined) { node.timestamp = attr.timestamp; } },lookup:function (parent, name) { throw new FS.ErrnoError(ERRNO_CODES.ENOENT); },mknod:function (parent, name, mode, dev) { throw new FS.ErrnoError(ERRNO_CODES.EPERM); },rename:function (oldNode, newDir, newName) { throw new FS.ErrnoError(ERRNO_CODES.EPERM); },unlink:function (parent, name) { throw new FS.ErrnoError(ERRNO_CODES.EPERM); },rmdir:function (parent, name) { throw new FS.ErrnoError(ERRNO_CODES.EPERM); },readdir:function (node) { throw new FS.ErrnoError(ERRNO_CODES.EPERM); },symlink:function (parent, newName, oldPath) { throw new FS.ErrnoError(ERRNO_CODES.EPERM); },readlink:function (node) { throw new FS.ErrnoError(ERRNO_CODES.EPERM); }},stream_ops:{read:function (stream, buffer, offset, length, position) { if (position >= 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) { // SEEK_CUR. position += stream.position; } else if (whence === 2) { // SEEK_END. 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) { // max recursive lookup of 8 throw new FS.ErrnoError(ERRNO_CODES.ELOOP); } // split the path var parts = PATH.normalizeArray(path.split('/').filter(function(p) { return !!p; }), false); // start at the root var current = FS.root; var current_path = '/'; for (var i = 0; i < parts.length; i++) { var islast = (i === parts.length-1); if (islast && opts.parent) { // stop resolving break; } current = FS.lookupNode(current, parts[i]); current_path = PATH.join2(current_path, parts[i]); // jump to the mount's root node if this is a mountpoint if (FS.isMountpoint(current)) { if (!islast || (islast && opts.follow_mount)) { current = current.mounted.root; } } // by default, lookupPath will not follow a symlink if it is the final path component. // setting opts.follow = true will override this behavior. if (!islast || opts.follow) { var count = 0; while (FS.isLink(current.mode)) { var link = FS.readlink(current_path); current_path = PATH.resolve(PATH.dirname(current_path), link); var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count }); current = lookup.node; if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX). 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 < name.length; i++) { hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0; } return ((parentid + hash) >>> 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; } } // if we failed to find it in the cache, call into the VFS 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; // root node sets parent to itself } 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 = {}; // compatibility var readMode = 292 | 73; var writeMode = 146; // NOTE we must use Object.defineProperties instead of individual calls to // Object.defineProperty in order to make closure compiler happy 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; } // return 0 if any user, group or owner bits are set. 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 || // opening for write (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 = {}; // compatibility 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); } } }); } // clone it, so we can return an instance of FSStream 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); // override node's stream ops with the device's stream.stream_ops = device.stream_ops; // forward the open call 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) & 0xff); },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); } }; // sync all mounts 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; // use the absolute 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: [] }; // create a root node for the fs var mountRoot = type.mount(mount); mountRoot.mount = mount; mount.root = mountRoot; if (root) { FS.root = mountRoot; } else if (node) { // set as a mountpoint node.mounted = mount; // add the new mount to the current mount's children 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); } // destroy the nodes for this mount, and all its child mounts 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; } }); // no longer a mountpoint node.mounted = null; // remove this mount from the child mounts 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 /* 0666 */; mode &= 4095; mode |= 32768; return FS.mknod(path, mode, 0); },mkdir:function (path, mode) { mode = mode !== undefined ? mode : 511 /* 0777 */; mode &= 511 | 512; mode |= 16384; return FS.mknod(path, mode, 0); },mkdev:function (path, mode, dev) { if (typeof(dev) === 'undefined') { dev = mode; mode = 438 /* 0666 */; } 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); // parents must exist 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); // need to be part of the same mount if (old_dir.mount !== new_dir.mount) { throw new FS.ErrnoError(ERRNO_CODES.EXDEV); } // source must exist var old_node = FS.lookupNode(old_dir, old_name); // old path should not be an ancestor of the new path var relative = PATH.relative(old_path, new_dirname); if (relative.charAt(0) !== '.') { throw new FS.ErrnoError(ERRNO_CODES.EINVAL); } // new path should not be an ancestor of the old path relative = PATH.relative(new_path, old_dirname); if (relative.charAt(0) !== '.') { throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY); } // see if the new path already exists var new_node; try { new_node = FS.lookupNode(new_dir, new_name); } catch (e) { // not fatal } // early out if nothing needs to change if (old_node === new_node) { return; } // we'll need to delete the old entry var isdir = FS.isDir(old_node.mode); var err = FS.mayDelete(old_dir, old_name, isdir); if (err) { throw new FS.ErrnoError(err); } // need delete permissions if we'll be overwriting. // need create permissions if new doesn't already exist. 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 we are going to change the parent, check write permissions 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); } // remove the node from the lookup hash FS.hashRemoveNode(old_node); // do the underlying fs rename try { old_dir.node_ops.rename(old_node, new_dir, new_name); } catch (e) { throw e; } finally { // add the node back to the hash (in case node_ops.rename // changed its name) 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) { // POSIX says unlink should set EPERM, not EISDIR 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() // we ignore the uid / gid for 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 /* 0666 */ : 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) { // ignore } } // perhaps we need to create the node var created = false; if ((flags & 64)) { if (node) { // if O_CREAT and O_EXCL are set, error out if the node already exists if ((flags & 128)) { throw new FS.ErrnoError(ERRNO_CODES.EEXIST); } } else { // node doesn't exist, try to create it node = FS.mknod(path, mode, 0); created = true; } } if (!node) { throw new FS.ErrnoError(ERRNO_CODES.ENOENT); } // can't truncate a device if (FS.isChrdev(node.mode)) { flags &= ~512; } // if asked only for a directory, then this must be one if ((flags & 65536) && !FS.isDir(node.mode)) { throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR); } // check permissions, if this is not a file we just created now (it is ok to // create and write to a file with read-only permissions; it is read-only // for later use) if (!created) { var err = FS.mayOpen(node, flags); if (err) { throw new FS.ErrnoError(err); } } // do truncation if necessary if ((flags & 512)) { FS.truncate(node, 0); } // we've already handled these, don't pass down to the underlying vfs flags &= ~(128 | 512); // register the stream with the filesystem var stream = FS.createStream({ node: node, path: FS.getPath(node), // we want the absolute path to the node flags: flags, seekable: true, position: 0, stream_ops: node.stream_ops, // used by the file family libc calls (fopen, fwrite, ferror, etc.) ungotten: [], error: false }, fd_start, fd_end); // call the new stream's open function 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; // free readdir state 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) { // seek to the end before writing in append mode 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) { // TODO if PROT is PROT_WRITE, make sure we have write access 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 () { // create /dev FS.mkdir('/dev'); // setup /dev/null 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)); // setup /dev/tty and /dev/tty1 // stderr needs to print output using Module['printErr'] // so we register a second tty just for it. 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)); // setup /dev/[u]random var random_device; if (typeof crypto !== 'undefined') { // for modern web browsers var randomBuffer = new Uint8Array(1); random_device = function() { crypto.getRandomValues(randomBuffer); return randomBuffer[0]; }; } else if (ENVIRONMENT_IS_NODE) { // for nodejs random_device = function() { return require('crypto').randomBytes(1)[0]; }; } else { // default for ES5 platforms random_device = function() { return (Math.random()*256)|0; }; } FS.createDevice('/dev', 'random', random_device); FS.createDevice('/dev', 'urandom', random_device); // we're not going to emulate the actual shm device, // just create the tmp dirs that reside in it commonly FS.mkdir('/dev/shm'); FS.mkdir('/dev/shm/tmp'); },createSpecialDirectories:function () { // create /proc/self/fd which allows /proc/self/fd/6 => readlink gives the name of the stream for fd 6 (see test_unistd_ttyname) FS.mkdir('/proc'); FS.mkdir('/proc/self'); FS.mkdir('/proc/self/fd'); FS.mount({ mount: function() { var node = FS.createNode('/proc/self', 'fd', 16384 | 0777, 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 } } }; ret.parent = ret; // make it look like a simple root node return ret; } }; return node; } }, {}, '/proc/self/fd'); },createStandardStreams:function () { // TODO deprecate the old functionality of a single // input / output callback and that utilizes FS.createDevice // and instead require a unique set of stream ops // by default, we symlink the standard streams to the // default tty devices. however, if the standard streams // have been overwritten we create a unique device for // them instead. if (Module['stdin']) { FS.createDevice('/dev', 'stdin', Module['stdin']); } else { FS.symlink('/dev/tty', '/dev/stdin'); } if (Module['stdout']) { FS.createDevice('/dev', 'stdout', null, Module['stdout']); } else { FS.symlink('/dev/tty', '/dev/stdout'); } if (Module['stderr']) { FS.createDevice('/dev', 'stderr', null, Module['stderr']); } else { FS.symlink('/dev/tty1', '/dev/stderr'); } // open default streams for the stdin, stdout and stderr devices var stdin = FS.open('/dev/stdin', 'r'); assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')'); var stdout = FS.open('/dev/stdout', 'w'); assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')'); var stderr = FS.open('/dev/stderr', 'w'); assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')'); },ensureErrnoError:function () { if (FS.ErrnoError) return; FS.ErrnoError = function ErrnoError(errno, node) { //Module.printErr(stackTrace()); // useful for debugging this.node = node; this.setErrno = function(errno) { this.errno = errno; for (var key in ERRNO_CODES) { if (ERRNO_CODES[key] === errno) { this.code = key; break; } } }; this.setErrno(errno); this.message = ERRNO_MESSAGES[errno]; if (this.stack) this.stack = demangleAll(this.stack); }; FS.ErrnoError.prototype = new Error(); FS.ErrnoError.prototype.constructor = FS.ErrnoError; // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info) [ERRNO_CODES.ENOENT].forEach(function(code) { FS.genericErrors[code] = new FS.ErrnoError(code); FS.genericErrors[code].stack = '<generic error, no stack>'; }); },staticInit:function () { FS.ensureErrnoError(); FS.nameTable = new Array(4096); FS.mount(MEMFS, {}, '/'); FS.createDefaultDirectories(); FS.createDefaultDevices(); FS.createSpecialDirectories(); FS.filesystems = { 'MEMFS': MEMFS, 'IDBFS': IDBFS, 'NODEFS': NODEFS, 'WORKERFS': WORKERFS, }; },init:function (input, output, error) { assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)'); FS.init.initialized = true; FS.ensureErrnoError(); // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here Module['stdin'] = input || Module['stdin']; Module['stdout'] = output || Module['stdout']; Module['stderr'] = error || Module['stderr']; FS.createStandardStreams(); },quit:function () { FS.init.initialized = false; // force-flush all streams, so we get musl std streams printed out var fflush = Module['_fflush']; if (fflush) fflush(0); // close all of our streams for (var i = 0; i < FS.streams.length; i++) { var stream = FS.streams[i]; if (!stream) { continue; } FS.close(stream); } },getMode:function (canRead, canWrite) { var mode = 0; if (canRead) mode |= 292 | 73; if (canWrite) mode |= 146; return mode; },joinPath:function (parts, forceRelative) { var path = PATH.join.apply(null, parts); if (forceRelative && path[0] == '/') path = path.substr(1); return path; },absolutePath:function (relative, base) { return PATH.resolve(base, relative); },standardizePath:function (path) { return PATH.normalize(path); },findObject:function (path, dontResolveLastLink) { var ret = FS.analyzePath(path, dontResolveLastLink); if (ret.exists) { return ret.object; } else { ___setErrNo(ret.error); return null; } },analyzePath:function (path, dontResolveLastLink) { // operate from within the context of the symlink's target try { var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink }); path = lookup.path; } catch (e) { } var ret = { isRoot: false, exists: false, error: 0, name: null, path: null, object: null, parentExists: false, parentPath: null, parentObject: null }; try { var lookup = FS.lookupPath(path, { parent: true }); ret.parentExists = true; ret.parentPath = lookup.path; ret.parentObject = lookup.node; ret.name = PATH.basename(path); lookup = FS.lookupPath(path, { follow: !dontResolveLastLink }); ret.exists = true; ret.path = lookup.path; ret.object = lookup.node; ret.name = lookup.node.name; ret.isRoot = lookup.path === '/'; } catch (e) { ret.error = e.errno; }; return ret; },createFolder:function (parent, name, canRead, canWrite) { var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name); var mode = FS.getMode(canRead, canWrite); return FS.mkdir(path, mode); },createPath:function (parent, path, canRead, canWrite) { parent = typeof parent === 'string' ? parent : FS.getPath(parent); var parts = path.split('/').reverse(); while (parts.length) { var part = parts.pop(); if (!part) continue; var current = PATH.join2(parent, part); try { FS.mkdir(current); } catch (e) { // ignore EEXIST } parent = current; } return current; },createFile:function (parent, name, properties, canRead, canWrite) { var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name); var mode = FS.getMode(canRead, canWrite); return FS.create(path, mode); },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) { var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent; var mode = FS.getMode(canRead, canWrite); var node = FS.create(path, mode); if (data) { if (typeof data === 'string') { var arr = new Array(data.length); for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i); data = arr; } // make sure we can write to the file FS.chmod(node, mode | 146); var stream = FS.open(node, 'w'); FS.write(stream, data, 0, data.length, 0, canOwn); FS.close(stream); FS.chmod(node, mode); } return node; },createDevice:function (parent, name, input, output) { var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name); var mode = FS.getMode(!!input, !!output); if (!FS.createDevice.major) FS.createDevice.major = 64; var dev = FS.makedev(FS.createDevice.major++, 0); // Create a fake device that a set of stream ops to emulate // the old behavior. FS.registerDevice(dev, { open: function(stream) { stream.seekable = false; }, close: function(stream) { // flush any pending line data if (output && output.buffer && output.buffer.length) { output(10); } }, read: function(stream, buffer, offset, length, pos /* ignored */) { var bytesRead = 0; for (var i = 0; i < length; i++) { var result; try { result = input(); } catch (e) { throw new FS.ErrnoError(ERRNO_CODES.EIO); } if (result === undefined && bytesRead === 0) { throw new FS.ErrnoError(ERRNO_CODES.EAGAIN); } if (result === null || result === undefined) break; bytesRead++; buffer[offset+i] = result; } if (bytesRead) { stream.node.timestamp = Date.now(); } return bytesRead; }, write: function(stream, buffer, offset, length, pos) { for (var i = 0; i < length; i++) { try { output(buffer[offset+i]); } catch (e) { throw new FS.ErrnoError(ERRNO_CODES.EIO); } } if (length) { stream.node.timestamp = Date.now(); } return i; } }); return FS.mkdev(path, mode, dev); },createLink:function (parent, name, target, canRead, canWrite) { var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name); return FS.symlink(target, path); },forceLoadFile:function (obj) { if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true; var success = true; if (typeof XMLHttpRequest !== 'undefined') { throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread."); } else if (Module['read']) { // Command-line. try { // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as // read() will try to parse UTF8. obj.contents = intArrayFromString(Module['read'](obj.url), true); obj.usedBytes = obj.contents.length; } catch (e) { success = false; } } else { throw new Error('Cannot load without read() or XMLHttpRequest.'); } if (!success) ___setErrNo(ERRNO_CODES.EIO); return success; },createLazyFile:function (parent, name, url, canRead, canWrite) { // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse. function LazyUint8Array() { this.lengthKnown = false; this.chunks = []; // Loaded chunks. Index is the chunk number } LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) { if (idx > this.length-1 || idx < 0) { return undefined; } var chunkOffset = idx % this.chunkSize; var chunkNum = (idx / this.chunkSize)|0; return this.getter(chunkNum)[chunkOffset]; } LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) { this.getter = getter; } LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() { // Find length var xhr = new XMLHttpRequest(); xhr.open('HEAD', url, false); xhr.send(null); if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status); var datalength = Number(xhr.getResponseHeader("Content-length")); var header; var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes"; var chunkSize = 1024*1024; // Chunk size in bytes if (!hasByteServing) chunkSize = datalength; // Function to get a range from the remote URL. var doXHR = (function(from, to) { if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!"); if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!"); // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available. var xhr = new XMLHttpRequest(); xhr.open('GET', url, false); if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to); // Some hints to the browser that we want binary data. if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer'; if (xhr.overrideMimeType) { xhr.overrideMimeType('text/plain; charset=x-user-defined'); } xhr.send(null); if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status); if (xhr.response !== undefined) { return new Uint8Array(xhr.response || []); } else { return intArrayFromString(xhr.responseText || '', true); } }); var lazyArray = this; lazyArray.setDataGetter(function(chunkNum) { var start = chunkNum * chunkSize; var end = (chunkNum+1) * chunkSize - 1; // including this byte end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block if (typeof(lazyArray.chunks[chunkNum]) === "undefined") { lazyArray.chunks[chunkNum] = doXHR(start, end); } if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!"); return lazyArray.chunks[chunkNum]; }); this._length = datalength; this._chunkSize = chunkSize; this.lengthKnown = true; } if (typeof XMLHttpRequest !== 'undefined') { if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc'; var lazyArray = new LazyUint8Array(); Object.defineProperty(lazyArray, "length", { get: function() { if(!this.lengthKnown) { this.cacheLength(); } return this._length; } }); Object.defineProperty(lazyArray, "chunkSize", { get: function() { if(!this.lengthKnown) { this.cacheLength(); } return this._chunkSize; } }); var properties = { isDevice: false, contents: lazyArray }; } else { var properties = { isDevice: false, url: url }; } var node = FS.createFile(parent, name, properties, canRead, canWrite); // This is a total hack, but I want to get this lazy file code out of the // core of MEMFS. If we want to keep this lazy file concept I feel it should // be its own thin LAZYFS proxying calls to MEMFS. if (properties.contents) { node.contents = properties.contents; } else if (properties.url) { node.contents = null; node.url = properties.url; } // Add a function that defers querying the file size until it is asked the first time. Object.defineProperty(node, "usedBytes", { get: function() { return this.contents.length; } }); // override each stream op with one that tries to force load the lazy file first var stream_ops = {}; var keys = Object.keys(node.stream_ops); keys.forEach(function(key) { var fn = node.stream_ops[key]; stream_ops[key] = function forceLoadLazyFile() { if (!FS.forceLoadFile(node)) { throw new FS.ErrnoError(ERRNO_CODES.EIO); } return fn.apply(null, arguments); }; }); // use a custom read function stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) { if (!FS.forceLoadFile(node)) { throw new FS.ErrnoError(ERRNO_CODES.EIO); } var contents = stream.node.contents; if (position >= contents.length) return 0; var size = Math.min(contents.length - position, length); assert(size >= 0); if (contents.slice) { // normal array for (var i = 0; i < size; i++) { buffer[offset + i] = contents[position + i]; } } else { for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR buffer[offset + i] = contents.get(position + i); } } return size; }; node.stream_ops = stream_ops; return node; },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) { Browser.init(); // TODO we should allow people to just pass in a complete filename instead // of parent and name being that we just join them anyways var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent; var dep = getUniqueRunDependency('cp ' + fullname); // might have several active requests for the same fullname function processData(byteArray) { function finish(byteArray) { if (preFinish) preFinish(); if (!dontCreateFile) { FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn); } if (onload) onload(); removeRunDependency(dep); } var handled = false; Module['preloadPlugins'].forEach(function(plugin) { if (handled) return; if (plugin['canHandle'](fullname)) { plugin['handle'](byteArray, fullname, finish, function() { if (onerror) onerror(); removeRunDependency(dep); }); handled = true; } }); if (!handled) finish(byteArray); } addRunDependency(dep); if (typeof url == 'string') { Browser.asyncLoad(url, function(byteArray) { processData(byteArray); }, onerror); } else { processData(url); } },indexedDB:function () { return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB; },DB_NAME:function () { return 'EM_FS_' + window.location.pathname; },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) { onload = onload || function(){}; onerror = onerror || function(){}; var indexedDB = FS.indexedDB(); try { var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION); } catch (e) { return onerror(e); } openRequest.onupgradeneeded = function openRequest_onupgradeneeded() { console.log('creating db'); var db = openRequest.result; db.createObjectStore(FS.DB_STORE_NAME); }; openRequest.onsuccess = function openRequest_onsuccess() { var db = openRequest.result; var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite'); var files = transaction.objectStore(FS.DB_STORE_NAME); var ok = 0, fail = 0, total = paths.length; function finish() { if (fail == 0) onload(); else onerror(); } paths.forEach(function(path) { var putRequest = files.put(FS.analyzePath(path).object.contents, path); putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() }; putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() }; }); transaction.onerror = onerror; }; openRequest.onerror = onerror; },loadFilesFromDB:function (paths, onload, onerror) { onload = onload || function(){}; onerror = onerror || function(){}; var indexedDB = FS.indexedDB(); try { var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION); } catch (e) { return onerror(e); } openRequest.onupgradeneeded = onerror; // no database to load from openRequest.onsuccess = function openRequest_onsuccess() { var db = openRequest.result; try { var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly'); } catch(e) { onerror(e); return; } var files = transaction.objectStore(FS.DB_STORE_NAME); var ok = 0, fail = 0, total = paths.length; function finish() { if (fail == 0) onload(); else onerror(); } paths.forEach(function(path) { var getRequest = files.get(path); getRequest.onsuccess = function getRequest_onsuccess() { if (FS.analyzePath(path).exists) { FS.unlink(path); } FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true); ok++; if (ok + fail == total) finish(); }; getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() }; }); transaction.onerror = onerror; }; openRequest.onerror = onerror; }};var PATH={splitPath:function (filename) { var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; return splitPathRe.exec(filename).slice(1); },normalizeArray:function (parts, allowAboveRoot) { // if the path tries to go above the root, `up` ends up > 0 var up = 0; for (var i = parts.length - 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 the path is allowed to go above the root, restore leading ..s if (allowAboveRoot) { for (; up--; up) { parts.unshift('..'); } } return parts; },normalize:function (path) { var isAbsolute = path.charAt(0) === '/', trailingSlash = path.substr(-1) === '/'; // Normalize the path 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) { // No dirname whatsoever return '.'; } if (dir) { // It has a dirname, strip trailing slash dir = dir.substr(0, dir.length - 1); } return root + dir; },basename:function (path) { // EMSCRIPTEN return '/'' for '/', not an empty string 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(); // Skip empty and invalid entries if (typeof path !== 'string') { throw new TypeError('Arguments to path.resolve must be strings'); } else if (!path) { return ''; // an invalid portion invalidates the whole thing } resolvedPath = path + '/' + resolvedPath; resolvedAbsolute = path.charAt(0) === '/'; } // At this point the path should be resolved to a full absolute path, but // handle relative paths to be safe (might happen when process.cwd() fails) 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 < arr.length; start++) { if (arr[start] !== '') break; } var end = arr.length - 1; for (; end >= 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; i < length; i++) { if (fromParts[i] !== toParts[i]) { samePartsLength = i; break; } } var outputParts = []; for (var i = samePartsLength; i < fromParts.length; i++) { outputParts.push('..'); } outputParts = outputParts.concat(toParts.slice(samePartsLength)); return outputParts.join('/'); }}; function _emscripten_set_main_loop_timing(mode, value) { Browser.mainLoop.timingMode = mode; Browser.mainLoop.timingValue = value; if (!Browser.mainLoop.func) { console.error('emscripten_set_main_loop_timing: Cannot set timing mode for main loop since a main loop does not exist! Call emscripten_set_main_loop first to set one up.'); return 1; // Return non-zero on failure, can't set timing mode when there is no main loop. } if (mode == 0 /*EM_TIMING_SETTIMEOUT*/) { Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler_setTimeout() { setTimeout(Browser.mainLoop.runner, value); // doing this each time means that on exception, we stop }; Browser.mainLoop.method = 'timeout'; } else if (mode == 1 /*EM_TIMING_RAF*/) { Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler_rAF() { Browser.requestAnimationFrame(Browser.mainLoop.runner); }; Browser.mainLoop.method = 'rAF'; } else if (mode == 2 /*EM_TIMING_SETIMMEDIATE*/) { if (!window['setImmediate']) { // Emulate setImmediate. (note: not a complete polyfill, we don't emulate clearImmediate() to keep code size to minimum, since not needed) var setImmediates = []; var emscriptenMainLoopMessageId = '__emcc'; function Browser_setImmediate_messageHandler(event) { if (event.source === window && event.data === emscriptenMainLoopMessageId) { event.stopPropagation(); setImmediates.shift()(); } } window.addEventListener("message", Browser_setImmediate_messageHandler, true); window['setImmediate'] = function Browser_emulated_setImmediate(func) { setImmediates.push(func); window.postMessage(emscriptenMainLoopMessageId, "*"); } } Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler_setImmediate() { window['setImmediate'](Browser.mainLoop.runner); }; Browser.mainLoop.method = 'immediate'; } return 0; }function _emscripten_set_main_loop(func, fps, simulateInfiniteLoop, arg, noSetTiming) { Module['noExitRuntime'] = true; assert(!Browser.mainLoop.func, 'emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters.'); Browser.mainLoop.func = func; Browser.mainLoop.arg = arg; var thisMainLoopId = Browser.mainLoop.currentlyRunningMainloop; Browser.mainLoop.runner = function Browser_mainLoop_runner() { if (ABORT) return; if (Browser.mainLoop.queue.length > 0) { var start = Date.now(); var blocker = Browser.mainLoop.queue.shift(); blocker.func(blocker.arg); if (Browser.mainLoop.remainingBlockers) { var remaining = Browser.mainLoop.remainingBlockers; var next = remaining%1 == 0 ? remaining-1 : Math.floor(remaining); if (blocker.counted) { Browser.mainLoop.remainingBlockers = next; } else { // not counted, but move the progress along a tiny bit next = next + 0.5; // do not steal all the next one's progress Browser.mainLoop.remainingBlockers = (8*remaining + next)/9; } } console.log('main loop blocker "' + blocker.name + '" took ' + (Date.now() - start) + ' ms'); //, left: ' + Browser.mainLoop.remainingBlockers); Browser.mainLoop.updateStatus(); setTimeout(Browser.mainLoop.runner, 0); return; } // catch pauses from non-main loop sources if (thisMainLoopId < Browser.mainLoop.currentlyRunningMainloop) return; // Implement very basic swap interval control Browser.mainLoop.currentFrameNumber = Browser.mainLoop.currentFrameNumber + 1 | 0; if (Browser.mainLoop.timingMode == 1/*EM_TIMING_RAF*/ && Browser.mainLoop.timingValue > 1 && Browser.mainLoop.currentFrameNumber % Browser.mainLoop.timingValue != 0) { // Not the scheduled time to render this frame - skip. Browser.mainLoop.scheduler(); return; } // Signal GL rendering layer that processing of a new frame is about to start. This helps it optimize // VBO double-buffering and reduce GPU stalls. if (Browser.mainLoop.method === 'timeout' && Module.ctx) { Module.printErr('Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!'); Browser.mainLoop.method = ''; // just warn once per call to set main loop } Browser.mainLoop.runIter(function() { if (typeof arg !== 'undefined') { Runtime.dynCall('vi', func, [arg]); } else { Runtime.dynCall('v', func); } }); // catch pauses from the main loop itself if (thisMainLoopId < Browser.mainLoop.currentlyRunningMainloop) return; // Queue new audio data. This is important to be right after the main loop invocation, so that we will immediately be able // to queue the newest produced audio samples. // TODO: Consider adding pre- and post- rAF callbacks so that GL.newRenderingFrameStarted() and SDL.audio.queueNewAudioData() // do not need to be hardcoded into this function, but can be more generic. if (typeof SDL === 'object' && SDL.audio && SDL.audio.queueNewAudioData) SDL.audio.queueNewAudioData(); Browser.mainLoop.scheduler(); } if (!noSetTiming) { if (fps && fps > 0) _emscripten_set_main_loop_timing(0/*EM_TIMING_SETTIMEOUT*/, 1000.0 / fps); else _emscripten_set_main_loop_timing(1/*EM_TIMING_RAF*/, 1); // Do rAF by rendering each frame (no decimating) Browser.mainLoop.scheduler(); } if (simulateInfiniteLoop) { throw 'SimulateInfiniteLoop'; } }var Browser={mainLoop:{scheduler:null,method:"",currentlyRunningMainloop:0,func:null,arg:0,timingMode:0,timingValue:0,currentFrameNumber:0,queue:[],pause:function () { Browser.mainLoop.scheduler = null; Browser.mainLoop.currentlyRunningMainloop++; // Incrementing this signals the previous main loop that it's now become old, and it must return. },resume:function () { Browser.mainLoop.currentlyRunningMainloop++; var timingMode = Browser.mainLoop.timingMode; var timingValue = Browser.mainLoop.timingValue; var func = Browser.mainLoop.func; Browser.mainLoop.func = null; _emscripten_set_main_loop(func, 0, false, Browser.mainLoop.arg, true /* do not set timing and call scheduler, we will do it on the next lines */); _emscripten_set_main_loop_timing(timingMode, timingValue); Browser.mainLoop.scheduler(); },updateStatus:function () { if (Module['setStatus']) { var message = Module['statusMessage'] || 'Please wait...'; var remaining = Browser.mainLoop.remainingBlockers; var expected = Browser.mainLoop.expectedBlockers; if (remaining) { if (remaining < expected) { Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')'); } else { Module['setStatus'](message); } } else { Module['setStatus'](''); } } },runIter:function (func) { if (ABORT) return; if (Module['preMainLoop']) { var preRet = Module['preMainLoop'](); if (preRet === false) { return; // |return false| skips a frame } } try { func(); } catch (e) { if (e instanceof ExitStatus) { return; } else { if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]); throw e; } } if (Module['postMainLoop']) Module['postMainLoop'](); }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () { if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers if (Browser.initted) return; Browser.initted = true; try { new Blob(); Browser.hasBlobConstructor = true; } catch(e) { Browser.hasBlobConstructor = false; console.log("warning: no blob constructor, cannot create blobs with mimetypes"); } Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null)); Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined; if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') { console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available."); Module.noImageDecoding = true; } // Support for plugins that can process preloaded files. You can add more of these to // your app by creating and appending to Module.preloadPlugins. // // Each plugin is asked if it can handle a file based on the file's name. If it can, // it is given the file's raw data. When it is done, it calls a callback with the file's // (possibly modified) data. For example, a plugin might decompress a file, or it // might create some side data structure for use later (like an Image element, etc.). var imagePlugin = {}; imagePlugin['canHandle'] = function imagePlugin_canHandle(name) { return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name); }; imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) { var b = null; if (Browser.hasBlobConstructor) { try { b = new Blob([byteArray], { type: Browser.getMimetype(name) }); if (b.size !== byteArray.length) { // Safari bug #118630 // Safari's Blob can only take an ArrayBuffer b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) }); } } catch(e) { Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder'); } } if (!b) { var bb = new Browser.BlobBuilder(); bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range b = bb.getBlob(); } var url = Browser.URLObject.createObjectURL(b); assert(typeof url == 'string', 'createObjectURL must return a url as a string'); var img = new Image(); img.onload = function img_onload() { assert(img.complete, 'Image ' + name + ' could not be decoded'); var canvas = document.createElement('canvas'); canvas.width = img.width; canvas.height = img.height; var ctx = canvas.getContext('2d'); ctx.drawImage(img, 0, 0); Module["preloadedImages"][name] = canvas; Browser.URLObject.revokeObjectURL(url); if (onload) onload(byteArray); }; img.onerror = function img_onerror(event) { console.log('Image ' + url + ' could not be decoded'); if (onerror) onerror(); }; img.src = url; }; Module['preloadPlugins'].push(imagePlugin); var audioPlugin = {}; audioPlugin['canHandle'] = function audioPlugin_canHandle(name) { return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 }; }; audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) { var done = false; function finish(audio) { if (done) return; done = true; Module["preloadedAudios"][name] = audio; if (onload) onload(byteArray); } function fail() { if (done) return; done = true; Module["preloadedAudios"][name] = new Audio(); // empty shim if (onerror) onerror(); } if (Browser.hasBlobConstructor) { try { var b = new Blob([byteArray], { type: Browser.getMimetype(name) }); } catch(e) { return fail(); } var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this! assert(typeof url == 'string', 'createObjectURL must return a url as a string'); var audio = new Audio(); audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926 audio.onerror = function audio_onerror(event) { if (done) return; console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach'); function encode64(data) { var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; var PAD = '='; var ret = ''; var leftchar = 0; var leftbits = 0; for (var i = 0; i < data.length; i++) { leftchar = (leftchar << 8) | data[i]; leftbits += 8; while (leftbits >= 6) { var curr = (leftchar >> (leftbits-6)) & 0x3f; leftbits -= 6; ret += BASE[curr]; } } if (leftbits == 2) { ret += BASE[(leftchar&3) << 4]; ret += PAD + PAD; } else if (leftbits == 4) { ret += BASE[(leftchar&0xf) << 2]; ret += PAD; } return ret; } audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray); finish(audio); // we don't wait for confirmation this worked - but it's worth trying }; audio.src = url; // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror Browser.safeSetTimeout(function() { finish(audio); // try to use it even though it is not necessarily ready to play }, 10000); } else { return fail(); } }; Module['preloadPlugins'].push(audioPlugin); // Canvas event setup var canvas = Module['canvas']; function pointerLockChange() { Browser.pointerLock = document['pointerLockElement'] === canvas || document['mozPointerLockElement'] === canvas || document['webkitPointerLockElement'] === canvas || document['msPointerLockElement'] === canvas; } if (canvas) { // forced aspect ratio can be enabled by defining 'forcedAspectRatio' on Module // Module['forcedAspectRatio'] = 4 / 3; canvas.requestPointerLock = canvas['requestPointerLock'] || canvas['mozRequestPointerLock'] || canvas['webkitRequestPointerLock'] || canvas['msRequestPointerLock'] || function(){}; canvas.exitPointerLock = document['exitPointerLock'] || document['mozExitPointerLock'] || document['webkitExitPointerLock'] || document['msExitPointerLock'] || function(){}; // no-op if function does not exist canvas.exitPointerLock = canvas.exitPointerLock.bind(document); document.addEventListener('pointerlockchange', pointerLockChange, false); document.addEventListener('mozpointerlockchange', pointerLockChange, false); document.addEventListener('webkitpointerlockchange', pointerLockChange, false); document.addEventListener('mspointerlockchange', pointerLockChange, false); if (Module['elementPointerLock']) { canvas.addEventListener("click", function(ev) { if (!Browser.pointerLock && canvas.requestPointerLock) { canvas.requestPointerLock(); ev.preventDefault(); } }, false); } } },createContext:function (canvas, useWebGL, setInModule, webGLContextAttributes) { if (useWebGL && Module.ctx && canvas == Module.canvas) return Module.ctx; // no need to recreate GL context if it's already been created for this canvas. var ctx; var contextHandle; if (useWebGL) { // For GLES2/desktop GL compatibility, adjust a few defaults to be different to WebGL defaults, so that they align better with the desktop defaults. var contextAttributes = { antialias: false, alpha: false }; if (webGLContextAttributes) { for (var attribute in webGLContextAttributes) { contextAttributes[attribute] = webGLContextAttributes[attribute]; } } contextHandle = GL.createContext(canvas, contextAttributes); if (contextHandle) { ctx = GL.getContext(contextHandle).GLctx; } // Set the background of the WebGL canvas to black canvas.style.backgroundColor = "black"; } else { ctx = canvas.getContext('2d'); } if (!ctx) return null; if (setInModule) { if (!useWebGL) assert(typeof GLctx === 'undefined', 'cannot set in module if GLctx is used, but we are a non-GL context that would replace it'); Module.ctx = ctx; if (useWebGL) GL.makeContextCurrent(contextHandle); Module.useWebGL = useWebGL; Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() }); Browser.init(); } return ctx; },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas, vrDevice) { Browser.lockPointer = lockPointer; Browser.resizeCanvas = resizeCanvas; Browser.vrDevice = vrDevice; if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true; if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false; if (typeof Browser.vrDevice === 'undefined') Browser.vrDevice = null; var canvas = Module['canvas']; function fullScreenChange() { Browser.isFullScreen = false; var canvasContainer = canvas.parentNode; if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] || document['mozFullScreenElement'] || document['mozFullscreenElement'] || document['fullScreenElement'] || document['fullscreenElement'] || document['msFullScreenElement'] || document['msFullscreenElement'] || document['webkitCurrentFullScreenElement']) === canvasContainer) { canvas.cancelFullScreen = document['cancelFullScreen'] || document['mozCancelFullScreen'] || document['webkitCancelFullScreen'] || document['msExitFullscreen'] || document['exitFullscreen'] || function() {}; canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document); if (Browser.lockPointer) canvas.requestPointerLock(); Browser.isFullScreen = true; if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize(); } else { // remove the full screen specific parent of the canvas again to restore the HTML structure from before going full screen canvasContainer.parentNode.insertBefore(canvas, canvasContainer); canvasContainer.parentNode.removeChild(canvasContainer); if (Browser.resizeCanvas) Browser.setWindowedCanvasSize(); } if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen); Browser.updateCanvasDimensions(canvas); } if (!Browser.fullScreenHandlersInstalled) { Browser.fullScreenHandlersInstalled = true; document.addEventListener('fullscreenchange', fullScreenChange, false); document.addEventListener('mozfullscreenchange', fullScreenChange, false); document.addEventListener('webkitfullscreenchange', fullScreenChange, false); document.addEventListener('MSFullscreenChange', fullScreenChange, false); } // create a new parent to ensure the canvas has no siblings. this allows browsers to optimize full screen performance when its parent is the full screen root var canvasContainer = document.createElement("div"); canvas.parentNode.insertBefore(canvasContainer, canvas); canvasContainer.appendChild(canvas); // use parent of canvas as full screen root to allow aspect ratio correction (Firefox stretches the root to screen size) canvasContainer.requestFullScreen = canvasContainer['requestFullScreen'] || canvasContainer['mozRequestFullScreen'] || canvasContainer['msRequestFullscreen'] || (canvasContainer['webkitRequestFullScreen'] ? function() { canvasContainer['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null); if (vrDevice) { canvasContainer.requestFullScreen({ vrDisplay: vrDevice }); } else { canvasContainer.requestFullScreen(); } },nextRAF:0,fakeRequestAnimationFrame:function (func) { // try to keep 60fps between calls to here var now = Date.now(); if (Browser.nextRAF === 0) { Browser.nextRAF = now + 1000/60; } else { while (now + 2 >= Browser.nextRAF) { // fudge a little, to avoid timer jitter causing us to do lots of delay:0 Browser.nextRAF += 1000/60; } } var delay = Math.max(Browser.nextRAF - now, 0); setTimeout(func, delay); },requestAnimationFrame:function requestAnimationFrame(func) { if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js) Browser.fakeRequestAnimationFrame(func); } else { if (!window.requestAnimationFrame) { window.requestAnimationFrame = window['requestAnimationFrame'] || window['mozRequestAnimationFrame'] || window['webkitRequestAnimationFrame'] || window['msRequestAnimationFrame'] || window['oRequestAnimationFrame'] || Browser.fakeRequestAnimationFrame; } window.requestAnimationFrame(func); } },safeCallback:function (func) { return function() { if (!ABORT) return func.apply(null, arguments); }; },allowAsyncCallbacks:true,queuedAsyncCallbacks:[],pauseAsyncCallbacks:function () { Browser.allowAsyncCallbacks = false; },resumeAsyncCallbacks:function () { // marks future callbacks as ok to execute, and synchronously runs any remaining ones right now Browser.allowAsyncCallbacks = true; if (Browser.queuedAsyncCallbacks.length > 0) { var callbacks = Browser.queuedAsyncCallbacks; Browser.queuedAsyncCallbacks = []; callbacks.forEach(function(func) { func(); }); } },safeRequestAnimationFrame:function (func) { return Browser.requestAnimationFrame(function() { if (ABORT) return; if (Browser.allowAsyncCallbacks) { func(); } else { Browser.queuedAsyncCallbacks.push(func); } }); },safeSetTimeout:function (func, timeout) { Module['noExitRuntime'] = true; return setTimeout(function() { if (ABORT) return; if (Browser.allowAsyncCallbacks) { func(); } else { Browser.queuedAsyncCallbacks.push(func); } }, timeout); },safeSetInterval:function (func, timeout) { Module['noExitRuntime'] = true; return setInterval(function() { if (ABORT) return; if (Browser.allowAsyncCallbacks) { func(); } // drop it on the floor otherwise, next interval will kick in }, timeout); },getMimetype:function (name) { return { 'jpg': 'image/jpeg', 'jpeg': 'image/jpeg', 'png': 'image/png', 'bmp': 'image/bmp', 'ogg': 'audio/ogg', 'wav': 'audio/wav', 'mp3': 'audio/mpeg' }[name.substr(name.lastIndexOf('.')+1)]; },getUserMedia:function (func) { if(!window.getUserMedia) { window.getUserMedia = navigator['getUserMedia'] || navigator['mozGetUserMedia']; } window.getUserMedia(func); },getMovementX:function (event) { return event['movementX'] || event['mozMovementX'] || event['webkitMovementX'] || 0; },getMovementY:function (event) { return event['movementY'] || event['mozMovementY'] || event['webkitMovementY'] || 0; },getMouseWheelDelta:function (event) { var delta = 0; switch (event.type) { case 'DOMMouseScroll': delta = event.detail; break; case 'mousewheel': delta = event.wheelDelta; break; case 'wheel': delta = event['deltaY']; break; default: throw 'unrecognized mouse wheel event: ' + event.type; } return delta; },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,touches:{},lastTouches:{},calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup if (Browser.pointerLock) { // When the pointer is locked, calculate the coordinates // based on the movement of the mouse. // Workaround for Firefox bug 764498 if (event.type != 'mousemove' && ('mozMovementX' in event)) { Browser.mouseMovementX = Browser.mouseMovementY = 0; } else { Browser.mouseMovementX = Browser.getMovementX(event); Browser.mouseMovementY = Browser.getMovementY(event); } // check if SDL is available if (typeof SDL != "undefined") { Browser.mouseX = SDL.mouseX + Browser.mouseMovementX; Browser.mouseY = SDL.mouseY + Browser.mouseMovementY; } else { // just add the mouse delta to the current absolut mouse position // FIXME: ideally this should be clamped against the canvas size and zero Browser.mouseX += Browser.mouseMovementX; Browser.mouseY += Browser.mouseMovementY; } } else { // Otherwise, calculate the movement based on the changes // in the coordinates. var rect = Module["canvas"].getBoundingClientRect(); var cw = Module["canvas"].width; var ch = Module["canvas"].height; // Neither .scrollX or .pageXOffset are defined in a spec, but // we prefer .scrollX because it is currently in a spec draft. // (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/) var scrollX = ((typeof window.scrollX !== 'undefined') ? window.scrollX : window.pageXOffset); var scrollY = ((typeof window.scrollY !== 'undefined') ? window.scrollY : window.pageYOffset); // If this assert lands, it's likely because the browser doesn't support scrollX or pageXOffset // and we have no viable fallback. assert((typeof scrollX !== 'undefined') && (typeof scrollY !== 'undefined'), 'Unable to retrieve scroll position, mouse positions likely broken.'); if (event.type === 'touchstart' || event.type === 'touchend' || event.type === 'touchmove') { var touch = event.touch; if (touch === undefined) { return; // the "touch" property is only defined in SDL } var adjustedX = touch.pageX - (scrollX + rect.left); var adjustedY = touch.pageY - (scrollY + rect.top); adjustedX = adjustedX * (cw / rect.width); adjustedY = adjustedY * (ch / rect.height); var coords = { x: adjustedX, y: adjustedY }; if (event.type === 'touchstart') { Browser.lastTouches[touch.identifier] = coords; Browser.touches[touch.identifier] = coords; } else if (event.type === 'touchend' || event.type === 'touchmove') { var last = Browser.touches[touch.identifier]; if (!last) last = coords; Browser.lastTouches[touch.identifier] = last; Browser.touches[touch.identifier] = coords; } return; } var x = event.pageX - (scrollX + rect.left); var y = event.pageY - (scrollY + rect.top); // the canvas might be CSS-scaled compared to its backbuffer; // SDL-using content will want mouse coordinates in terms // of backbuffer units. x = x * (cw / rect.width); y = y * (ch / rect.height); Browser.mouseMovementX = x - Browser.mouseX; Browser.mouseMovementY = y - Browser.mouseY; Browser.mouseX = x; Browser.mouseY = y; } },xhrLoad:function (url, onload, onerror) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; xhr.onload = function xhr_onload() { if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0 onload(xhr.response); } else { onerror(); } }; xhr.onerror = onerror; xhr.send(null); },asyncLoad:function (url, onload, onerror, noRunDep) { Browser.xhrLoad(url, function(arrayBuffer) { assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).'); onload(new Uint8Array(arrayBuffer)); if (!noRunDep) removeRunDependency('al ' + url); }, function(event) { if (onerror) { onerror(); } else { throw 'Loading data file "' + url + '" failed.'; } }); if (!noRunDep) addRunDependency('al ' + url); },resizeListeners:[],updateResizeListeners:function () { var canvas = Module['canvas']; Browser.resizeListeners.forEach(function(listener) { listener(canvas.width, canvas.height); }); },setCanvasSize:function (width, height, noUpdates) { var canvas = Module['canvas']; Browser.updateCanvasDimensions(canvas, width, height); if (!noUpdates) Browser.updateResizeListeners(); },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () { // check if SDL is available if (typeof SDL != "undefined") { var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]; flags = flags | 0x00800000; // set SDL_FULLSCREEN flag HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags } Browser.updateResizeListeners(); },setWindowedCanvasSize:function () { // check if SDL is available if (typeof SDL != "undefined") { var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]; flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags } Browser.updateResizeListeners(); },updateCanvasDimensions:function (canvas, wNative, hNative) { if (wNative && hNative) { canvas.widthNative = wNative; canvas.heightNative = hNative; } else { wNative = canvas.widthNative; hNative = canvas.heightNative; } var w = wNative; var h = hNative; if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) { if (w/h < Module['forcedAspectRatio']) { w = Math.round(h * Module['forcedAspectRatio']); } else { h = Math.round(w / Module['forcedAspectRatio']); } } if (((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] || document['mozFullScreenElement'] || document['mozFullscreenElement'] || document['fullScreenElement'] || document['fullscreenElement'] || document['msFullScreenElement'] || document['msFullscreenElement'] || document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) { var factor = Math.min(screen.width / w, screen.height / h); w = Math.round(w * factor); h = Math.round(h * factor); } if (Browser.resizeCanvas) { if (canvas.width != w) canvas.width = w; if (canvas.height != h) canvas.height = h; if (typeof canvas.style != 'undefined') { canvas.style.removeProperty( "width"); canvas.style.removeProperty("height"); } } else { if (canvas.width != wNative) canvas.width = wNative; if (canvas.height != hNative) canvas.height = hNative; if (typeof canvas.style != 'undefined') { if (w != wNative || h != hNative) { canvas.style.setProperty( "width", w + "px", "important"); canvas.style.setProperty("height", h + "px", "important"); } else { canvas.style.removeProperty( "width"); canvas.style.removeProperty("height"); } } } },wgetRequests:{},nextWgetRequestHandle:0,getNextWgetRequestHandle:function () { var handle = Browser.nextWgetRequestHandle; Browser.nextWgetRequestHandle++; return handle; }}; function _time(ptr) { var ret = (Date.now()/1000)|0; if (ptr) { HEAP32[((ptr)>>2)]=ret; } return ret; } function _pthread_self() { //FIXME: assumes only a single thread return 0; } function _emscripten_memcpy_big(dest, src, num) { HEAPU8.set(HEAPU8.subarray(src, src+num), dest); return dest; } Module["_memcpy"] = _memcpy; Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas, vrDevice) { Browser.requestFullScreen(lockPointer, resizeCanvas, vrDevice) }; Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) }; Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) }; Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() }; Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() }; Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() } Module["createContext"] = function Module_createContext(canvas, useWebGL, setInModule, webGLContextAttributes) { return Browser.createContext(canvas, useWebGL, setInModule, webGLContextAttributes) } FS.staticInit();__ATINIT__.unshift(function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() });__ATMAIN__.push(function() { FS.ignorePermissions = false });__ATEXIT__.push(function() { FS.quit() });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;Module["FS_unlink"] = FS.unlink; __ATINIT__.unshift(function() { TTY.init() });__ATEXIT__.push(function() { TTY.shutdown() }); if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); var NODEJS_PATH = require("path"); NODEFS.staticInit(); } STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP); staticSealed = true; // seal the static portion of memory STACK_MAX = STACK_BASE + TOTAL_STACK; DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX); assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack"); function nullFunc_vi(x) { Module["printErr"]("Invalid function pointer called with signature 'vi'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); Module["printErr"]("Build with ASSERTIONS=2 for more info.");abort(x) } function nullFunc_viii(x) { Module["printErr"]("Invalid function pointer called with signature 'viii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)"); Module["printErr"]("Build with ASSERTIONS=2 for more info.");abort(x) } function invoke_vi(index,a1) { try { Module["dynCall_vi"](index,a1); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } function invoke_viii(index,a1,a2,a3) { try { Module["dynCall_viii"](index,a1,a2,a3); } catch(e) { if (typeof e !== 'number' && e !== 'longjmp') throw e; asm["setThrew"](1, 0); } } Module.asmGlobalArg = { "Math": Math, "Int8Array": Int8Array, "Int16Array": Int16Array, "Int32Array": Int32Array, "Uint8Array": Uint8Array, "Uint16Array": Uint16Array, "Uint32Array": Uint32Array, "Float32Array": Float32Array, "Float64Array": Float64Array, "NaN": NaN, "Infinity": Infinity }; Module.asmLibraryArg = { "abort": abort, "assert": assert, "nullFunc_vi": nullFunc_vi, "nullFunc_viii": nullFunc_viii, "invoke_vi": invoke_vi, "invoke_viii": invoke_viii, "_emscripten_asm_const_3": _emscripten_asm_const_3, "_pthread_self": _pthread_self, "_emscripten_set_main_loop": _emscripten_set_main_loop, "_abort": _abort, "___setErrNo": ___setErrNo, "_sbrk": _sbrk, "_time": _time, "_emscripten_set_main_loop_timing": _emscripten_set_main_loop_timing, "_emscripten_memcpy_big": _emscripten_memcpy_big, "_sysconf": _sysconf, "_emscripten_asm_const_1": _emscripten_asm_const_1, "_emscripten_asm_const_0": _emscripten_asm_const_0, "STACKTOP": STACKTOP, "STACK_MAX": STACK_MAX, "tempDoublePtr": tempDoublePtr, "ABORT": ABORT }; // EMSCRIPTEN_START_ASM var asm = (function(global, env, buffer) { 'almost asm'; var HEAP8 = new global.Int8Array(buffer); var HEAP16 = new global.Int16Array(buffer); var HEAP32 = new global.Int32Array(buffer); var HEAPU8 = new global.Uint8Array(buffer); var HEAPU16 = new global.Uint16Array(buffer); var HEAPU32 = new global.Uint32Array(buffer); var HEAPF32 = new global.Float32Array(buffer); var HEAPF64 = new global.Float64Array(buffer); var STACKTOP=env.STACKTOP|0; var STACK_MAX=env.STACK_MAX|0; var tempDoublePtr=env.tempDoublePtr|0; var ABORT=env.ABORT|0; var __THREW__ = 0; var threwValue = 0; var setjmpId = 0; var undef = 0; var nan = global.NaN, inf = global.Infinity; var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0; var tempRet0 = 0; var tempRet1 = 0; var tempRet2 = 0; var tempRet3 = 0; var tempRet4 = 0; var tempRet5 = 0; var tempRet6 = 0; var tempRet7 = 0; var tempRet8 = 0; var tempRet9 = 0; var Math_floor=global.Math.floor; var Math_abs=global.Math.abs; var Math_sqrt=global.Math.sqrt; var Math_pow=global.Math.pow; var Math_cos=global.Math.cos; var Math_sin=global.Math.sin; var Math_tan=global.Math.tan; var Math_acos=global.Math.acos; var Math_asin=global.Math.asin; var Math_atan=global.Math.atan; var Math_atan2=global.Math.atan2; var Math_exp=global.Math.exp; var Math_log=global.Math.log; var Math_ceil=global.Math.ceil; var Math_imul=global.Math.imul; var Math_min=global.Math.min; var Math_clz32=global.Math.clz32; var abort=env.abort; var assert=env.assert; var nullFunc_vi=env.nullFunc_vi; var nullFunc_viii=env.nullFunc_viii; var invoke_vi=env.invoke_vi; var invoke_viii=env.invoke_viii; var _emscripten_asm_const_3=env._emscripten_asm_const_3; var _pthread_self=env._pthread_self; var _emscripten_set_main_loop=env._emscripten_set_main_loop; var _abort=env._abort; var ___setErrNo=env.___setErrNo; var _sbrk=env._sbrk; var _time=env._time; var _emscripten_set_main_loop_timing=env._emscripten_set_main_loop_timing; var _emscripten_memcpy_big=env._emscripten_memcpy_big; var _sysconf=env._sysconf; var _emscripten_asm_const_1=env._emscripten_asm_const_1; var _emscripten_asm_const_0=env._emscripten_asm_const_0; var tempFloat = 0.0; // EMSCRIPTEN_START_FUNCS function stackAlloc(size) { size = size|0; var ret = 0; ret = STACKTOP; STACKTOP = (STACKTOP + size)|0; STACKTOP = (STACKTOP + 15)&-16; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); return ret|0; } function stackSave() { return STACKTOP|0; } function stackRestore(top) { top = top|0; STACKTOP = top; } function establishStackSpace(stackBase, stackMax) { stackBase = stackBase|0; stackMax = stackMax|0; STACKTOP = stackBase; STACK_MAX = stackMax; } function setThrew(threw, value) { threw = threw|0; value = value|0; if ((__THREW__|0) == 0) { __THREW__ = threw; threwValue = value; } } function copyTempFloat(ptr) { ptr = ptr|0; HEAP8[tempDoublePtr>>0] = HEAP8[ptr>>0]; HEAP8[tempDoublePtr+1>>0] = HEAP8[ptr+1>>0]; HEAP8[tempDoublePtr+2>>0] = HEAP8[ptr+2>>0]; HEAP8[tempDoublePtr+3>>0] = HEAP8[ptr+3>>0]; } function copyTempDouble(ptr) { ptr = ptr|0; HEAP8[tempDoublePtr>>0] = HEAP8[ptr>>0]; HEAP8[tempDoublePtr+1>>0] = HEAP8[ptr+1>>0]; HEAP8[tempDoublePtr+2>>0] = HEAP8[ptr+2>>0]; HEAP8[tempDoublePtr+3>>0] = HEAP8[ptr+3>>0]; HEAP8[tempDoublePtr+4>>0] = HEAP8[ptr+4>>0]; HEAP8[tempDoublePtr+5>>0] = HEAP8[ptr+5>>0]; HEAP8[tempDoublePtr+6>>0] = HEAP8[ptr+6>>0]; HEAP8[tempDoublePtr+7>>0] = HEAP8[ptr+7>>0]; } function setTempRet0(value) { value = value|0; tempRet0 = value; } function getTempRet0() { return tempRet0|0; } function _fake_os_getActiveVesaBuffer($width,$height) { $width = $width|0; $height = $height|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $i = 0, $return_buffer = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $width; $2 = $height; $return_buffer = 0; $3 = $1; HEAP16[$3>>1] = 0; $4 = $2; HEAP16[$4>>1] = 0; $5 = (_malloc(3145728)|0); $return_buffer = $5; $6 = ($5|0)!=(0|0); if (!($6)) { $7 = $return_buffer; $0 = $7; $27 = $0; STACKTOP = sp;return ($27|0); } $8 = $1; HEAP16[$8>>1] = 1024; $9 = $2; HEAP16[$9>>1] = 768; $i = 0; while(1) { $10 = $i; $11 = $1; $12 = HEAP16[$11>>1]|0; $13 = $12&65535; $14 = $2; $15 = HEAP16[$14>>1]|0; $16 = $15&65535; $17 = Math_imul($13, $16)|0; $18 = ($10|0)<($17|0); if (!($18)) { break; } $19 = $i; $20 = $return_buffer; $21 = (($20) + ($19<<2)|0); HEAP32[$21>>2] = -16777216; $22 = $i; $23 = (($22) + 1)|0; $i = $23; } $24 = $return_buffer; $25 = _emscripten_asm_const_3(0, 1024, 768, ($24|0))|0; $26 = $return_buffer; $0 = $26; $27 = $0; STACKTOP = sp;return ($27|0); } function _fake_os_doMouseCallback() { var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $buttons = 0, $mouse_x = 0, $mouse_y = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = HEAP32[8>>2]|0; $1 = ($0|0)!=(0|0); if (!($1)) { STACKTOP = sp;return; } $2 = _emscripten_asm_const_1(1, 0)|0; $3 = $2&65535; $mouse_x = $3; $4 = _emscripten_asm_const_1(2, 0)|0; $5 = $4&65535; $mouse_y = $5; $6 = _emscripten_asm_const_1(3, 0)|0; $7 = $6&255; $buttons = $7; $8 = HEAP32[8>>2]|0; $9 = $mouse_x; $10 = $mouse_y; $11 = $buttons; FUNCTION_TABLE_viii[$8 & 15]($9,$10,$11); STACKTOP = sp;return; } function _fake_os_installMouseCallback($new_handler) { $new_handler = $new_handler|0; var $0 = 0, $1 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $new_handler; _fake_os_doMouseCallback(); _emscripten_asm_const_0(4); $1 = $0; HEAP32[8>>2] = $1; STACKTOP = sp;return; } function _ListNode_new($payload) { $payload = $payload|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $list_node = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $payload; $2 = (_malloc(12)|0); $list_node = $2; $3 = ($2|0)!=(0|0); $4 = $list_node; if ($3) { $5 = ((($4)) + 4|0); HEAP32[$5>>2] = 0; $6 = $list_node; $7 = ((($6)) + 8|0); HEAP32[$7>>2] = 0; $8 = $1; $9 = $list_node; HEAP32[$9>>2] = $8; $10 = $list_node; $0 = $10; $11 = $0; STACKTOP = sp;return ($11|0); } else { $0 = $4; $11 = $0; STACKTOP = sp;return ($11|0); } return (0)|0; } function _Calculator_button_handler($button,$x,$y) { $button = $button|0; $x = $x|0; $y = $y|0; var $0 = 0, $1 = 0, $10 = 0, $100 = 0, $101 = 0, $102 = 0, $103 = 0, $104 = 0, $105 = 0, $106 = 0, $107 = 0, $108 = 0, $109 = 0, $11 = 0, $110 = 0, $111 = 0, $112 = 0, $113 = 0, $114 = 0, $115 = 0; var $116 = 0, $117 = 0, $118 = 0, $119 = 0, $12 = 0, $120 = 0, $121 = 0, $122 = 0, $123 = 0, $124 = 0, $125 = 0, $126 = 0, $127 = 0, $128 = 0, $129 = 0, $13 = 0, $130 = 0, $131 = 0, $132 = 0, $133 = 0; var $134 = 0, $135 = 0, $136 = 0, $137 = 0, $138 = 0, $139 = 0, $14 = 0, $140 = 0, $141 = 0, $142 = 0, $143 = 0, $144 = 0, $145 = 0, $146 = 0, $147 = 0, $148 = 0, $149 = 0, $15 = 0, $150 = 0, $151 = 0; var $152 = 0, $153 = 0, $154 = 0, $155 = 0, $156 = 0, $157 = 0, $158 = 0, $159 = 0, $16 = 0, $160 = 0, $161 = 0, $162 = 0, $163 = 0, $164 = 0, $165 = 0, $166 = 0, $167 = 0, $168 = 0, $169 = 0, $17 = 0; var $170 = 0, $171 = 0, $172 = 0, $173 = 0, $174 = 0, $175 = 0, $176 = 0, $177 = 0, $178 = 0, $179 = 0, $18 = 0, $180 = 0, $181 = 0, $182 = 0, $183 = 0, $184 = 0, $185 = 0, $186 = 0, $187 = 0, $188 = 0; var $189 = 0, $19 = 0, $190 = 0, $191 = 0, $192 = 0, $193 = 0, $194 = 0, $195 = 0, $196 = 0, $197 = 0, $198 = 0, $199 = 0, $2 = 0, $20 = 0, $200 = 0, $201 = 0, $202 = 0, $203 = 0, $204 = 0, $205 = 0; var $206 = 0, $207 = 0, $208 = 0, $209 = 0, $21 = 0, $210 = 0, $211 = 0, $212 = 0, $213 = 0, $214 = 0, $215 = 0, $216 = 0, $217 = 0, $218 = 0, $219 = 0, $22 = 0, $220 = 0, $221 = 0, $222 = 0, $223 = 0; var $224 = 0, $225 = 0, $226 = 0, $227 = 0, $228 = 0, $229 = 0, $23 = 0, $230 = 0, $231 = 0, $232 = 0, $233 = 0, $234 = 0, $235 = 0, $236 = 0, $237 = 0, $238 = 0, $239 = 0, $24 = 0, $240 = 0, $241 = 0; var $242 = 0, $243 = 0, $244 = 0, $245 = 0, $246 = 0, $247 = 0, $248 = 0, $249 = 0, $25 = 0, $250 = 0, $251 = 0, $252 = 0, $253 = 0, $254 = 0, $255 = 0, $256 = 0, $257 = 0, $258 = 0, $259 = 0, $26 = 0; var $260 = 0, $261 = 0, $262 = 0, $263 = 0, $264 = 0, $265 = 0, $266 = 0, $267 = 0, $268 = 0, $269 = 0, $27 = 0, $270 = 0, $271 = 0, $272 = 0, $273 = 0, $274 = 0, $275 = 0, $276 = 0, $277 = 0, $278 = 0; var $279 = 0, $28 = 0, $280 = 0, $281 = 0, $282 = 0, $283 = 0, $284 = 0, $285 = 0, $286 = 0, $287 = 0, $288 = 0, $289 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0; var $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0, $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0; var $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0, $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0, $71 = 0; var $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0, $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0, $9 = 0; var $90 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $95 = 0, $96 = 0, $97 = 0, $98 = 0, $99 = 0, $calculator = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $button; $1 = $x; $2 = $y; $3 = $0; $4 = HEAP32[$3>>2]|0; $calculator = $4; $5 = $0; $6 = $calculator; $7 = ((($6)) + 92|0); $8 = HEAP32[$7>>2]|0; $9 = ($5|0)==($8|0); do { if ($9) { $10 = $calculator; $11 = ((($10)) + 52|0); $12 = HEAP32[$11>>2]|0; $13 = ((($12)) + 48|0); $14 = HEAP32[$13>>2]|0; $15 = HEAP8[$14>>0]|0; $16 = $15 << 24 >> 24; $17 = ($16|0)==(48); if ($17) { $18 = $calculator; $19 = ((($18)) + 52|0); $20 = HEAP32[$19>>2]|0; $21 = ((($20)) + 48|0); $22 = HEAP32[$21>>2]|0; $23 = ((($22)) + 1|0); $24 = HEAP8[$23>>0]|0; $25 = $24 << 24 >> 24; $26 = ($25|0)==(0); if ($26) { break; } } $27 = $calculator; $28 = ((($27)) + 52|0); $29 = HEAP32[$28>>2]|0; _Window_append_title($29,2509); } } while(0); $30 = $0; $31 = $calculator; $32 = ((($31)) + 56|0); $33 = HEAP32[$32>>2]|0; $34 = ($30|0)==($33|0); do { if ($34) { $35 = $calculator; $36 = ((($35)) + 52|0); $37 = HEAP32[$36>>2]|0; $38 = ((($37)) + 48|0); $39 = HEAP32[$38>>2]|0; $40 = HEAP8[$39>>0]|0; $41 = $40 << 24 >> 24; $42 = ($41|0)==(48); if ($42) { $43 = $calculator; $44 = ((($43)) + 52|0); $45 = HEAP32[$44>>2]|0; $46 = ((($45)) + 48|0); $47 = HEAP32[$46>>2]|0; $48 = ((($47)) + 1|0); $49 = HEAP8[$48>>0]|0; $50 = $49 << 24 >> 24; $51 = ($50|0)==(0); if ($51) { $55 = $calculator; $56 = ((($55)) + 52|0); $57 = HEAP32[$56>>2]|0; _Window_set_title($57,2511); break; } } $52 = $calculator; $53 = ((($52)) + 52|0); $54 = HEAP32[$53>>2]|0; _Window_append_title($54,2511); } } while(0); $58 = $0; $59 = $calculator; $60 = ((($59)) + 60|0); $61 = HEAP32[$60>>2]|0; $62 = ($58|0)==($61|0); do { if ($62) { $63 = $calculator; $64 = ((($63)) + 52|0); $65 = HEAP32[$64>>2]|0; $66 = ((($65)) + 48|0); $67 = HEAP32[$66>>2]|0; $68 = HEAP8[$67>>0]|0; $69 = $68 << 24 >> 24; $70 = ($69|0)==(48); if ($70) { $71 = $calculator; $72 = ((($71)) + 52|0); $73 = HEAP32[$72>>2]|0; $74 = ((($73)) + 48|0); $75 = HEAP32[$74>>2]|0; $76 = ((($75)) + 1|0); $77 = HEAP8[$76>>0]|0; $78 = $77 << 24 >> 24; $79 = ($78|0)==(0); if ($79) { $83 = $calculator; $84 = ((($83)) + 52|0); $85 = HEAP32[$84>>2]|0; _Window_set_title($85,2513); break; } } $80 = $calculator; $81 = ((($80)) + 52|0); $82 = HEAP32[$81>>2]|0; _Window_append_title($82,2513); } } while(0); $86 = $0; $87 = $calculator; $88 = ((($87)) + 64|0); $89 = HEAP32[$88>>2]|0; $90 = ($86|0)==($89|0); do { if ($90) { $91 = $calculator; $92 = ((($91)) + 52|0); $93 = HEAP32[$92>>2]|0; $94 = ((($93)) + 48|0); $95 = HEAP32[$94>>2]|0; $96 = HEAP8[$95>>0]|0; $97 = $96 << 24 >> 24; $98 = ($97|0)==(48); if ($98) { $99 = $calculator; $100 = ((($99)) + 52|0); $101 = HEAP32[$100>>2]|0; $102 = ((($101)) + 48|0); $103 = HEAP32[$102>>2]|0; $104 = ((($103)) + 1|0); $105 = HEAP8[$104>>0]|0; $106 = $105 << 24 >> 24; $107 = ($106|0)==(0); if ($107) { $111 = $calculator; $112 = ((($111)) + 52|0); $113 = HEAP32[$112>>2]|0; _Window_set_title($113,2515); break; } } $108 = $calculator; $109 = ((($108)) + 52|0); $110 = HEAP32[$109>>2]|0; _Window_append_title($110,2515); } } while(0); $114 = $0; $115 = $calculator; $116 = ((($115)) + 68|0); $117 = HEAP32[$116>>2]|0; $118 = ($114|0)==($117|0); do { if ($118) { $119 = $calculator; $120 = ((($119)) + 52|0); $121 = HEAP32[$120>>2]|0; $122 = ((($121)) + 48|0); $123 = HEAP32[$122>>2]|0; $124 = HEAP8[$123>>0]|0; $125 = $124 << 24 >> 24; $126 = ($125|0)==(48); if ($126) { $127 = $calculator; $128 = ((($127)) + 52|0); $129 = HEAP32[$128>>2]|0; $130 = ((($129)) + 48|0); $131 = HEAP32[$130>>2]|0; $132 = ((($131)) + 1|0); $133 = HEAP8[$132>>0]|0; $134 = $133 << 24 >> 24; $135 = ($134|0)==(0); if ($135) { $139 = $calculator; $140 = ((($139)) + 52|0); $141 = HEAP32[$140>>2]|0; _Window_set_title($141,2517); break; } } $136 = $calculator; $137 = ((($136)) + 52|0); $138 = HEAP32[$137>>2]|0; _Window_append_title($138,2517); } } while(0); $142 = $0; $143 = $calculator; $144 = ((($143)) + 72|0); $145 = HEAP32[$144>>2]|0; $146 = ($142|0)==($145|0); do { if ($146) { $147 = $calculator; $148 = ((($147)) + 52|0); $149 = HEAP32[$148>>2]|0; $150 = ((($149)) + 48|0); $151 = HEAP32[$150>>2]|0; $152 = HEAP8[$151>>0]|0; $153 = $152 << 24 >> 24; $154 = ($153|0)==(48); if ($154) { $155 = $calculator; $156 = ((($155)) + 52|0); $157 = HEAP32[$156>>2]|0; $158 = ((($157)) + 48|0); $159 = HEAP32[$158>>2]|0; $160 = ((($159)) + 1|0); $161 = HEAP8[$160>>0]|0; $162 = $161 << 24 >> 24; $163 = ($162|0)==(0); if ($163) { $167 = $calculator; $168 = ((($167)) + 52|0); $169 = HEAP32[$168>>2]|0; _Window_set_title($169,2519); break; } } $164 = $calculator; $165 = ((($164)) + 52|0); $166 = HEAP32[$165>>2]|0; _Window_append_title($166,2519); } } while(0); $170 = $0; $171 = $calculator; $172 = ((($171)) + 76|0); $173 = HEAP32[$172>>2]|0; $174 = ($170|0)==($173|0); do { if ($174) { $175 = $calculator; $176 = ((($175)) + 52|0); $177 = HEAP32[$176>>2]|0; $178 = ((($177)) + 48|0); $179 = HEAP32[$178>>2]|0; $180 = HEAP8[$179>>0]|0; $181 = $180 << 24 >> 24; $182 = ($181|0)==(48); if ($182) { $183 = $calculator; $184 = ((($183)) + 52|0); $185 = HEAP32[$184>>2]|0; $186 = ((($185)) + 48|0); $187 = HEAP32[$186>>2]|0; $188 = ((($187)) + 1|0); $189 = HEAP8[$188>>0]|0; $190 = $189 << 24 >> 24; $191 = ($190|0)==(0); if ($191) { $195 = $calculator; $196 = ((($195)) + 52|0); $197 = HEAP32[$196>>2]|0; _Window_set_title($197,2521); break; } } $192 = $calculator; $193 = ((($192)) + 52|0); $194 = HEAP32[$193>>2]|0; _Window_append_title($194,2521); } } while(0); $198 = $0; $199 = $calculator; $200 = ((($199)) + 80|0); $201 = HEAP32[$200>>2]|0; $202 = ($198|0)==($201|0); do { if ($202) { $203 = $calculator; $204 = ((($203)) + 52|0); $205 = HEAP32[$204>>2]|0; $206 = ((($205)) + 48|0); $207 = HEAP32[$206>>2]|0; $208 = HEAP8[$207>>0]|0; $209 = $208 << 24 >> 24; $210 = ($209|0)==(48); if ($210) { $211 = $calculator; $212 = ((($211)) + 52|0); $213 = HEAP32[$212>>2]|0; $214 = ((($213)) + 48|0); $215 = HEAP32[$214>>2]|0; $216 = ((($215)) + 1|0); $217 = HEAP8[$216>>0]|0; $218 = $217 << 24 >> 24; $219 = ($218|0)==(0); if ($219) { $223 = $calculator; $224 = ((($223)) + 52|0); $225 = HEAP32[$224>>2]|0; _Window_set_title($225,2523); break; } } $220 = $calculator; $221 = ((($220)) + 52|0); $222 = HEAP32[$221>>2]|0; _Window_append_title($222,2523); } } while(0); $226 = $0; $227 = $calculator; $228 = ((($227)) + 84|0); $229 = HEAP32[$228>>2]|0; $230 = ($226|0)==($229|0); do { if ($230) { $231 = $calculator; $232 = ((($231)) + 52|0); $233 = HEAP32[$232>>2]|0; $234 = ((($233)) + 48|0); $235 = HEAP32[$234>>2]|0; $236 = HEAP8[$235>>0]|0; $237 = $236 << 24 >> 24; $238 = ($237|0)==(48); if ($238) { $239 = $calculator; $240 = ((($239)) + 52|0); $241 = HEAP32[$240>>2]|0; $242 = ((($241)) + 48|0); $243 = HEAP32[$242>>2]|0; $244 = ((($243)) + 1|0); $245 = HEAP8[$244>>0]|0; $246 = $245 << 24 >> 24; $247 = ($246|0)==(0); if ($247) { $251 = $calculator; $252 = ((($251)) + 52|0); $253 = HEAP32[$252>>2]|0; _Window_set_title($253,2525); break; } } $248 = $calculator; $249 = ((($248)) + 52|0); $250 = HEAP32[$249>>2]|0; _Window_append_title($250,2525); } } while(0); $254 = $0; $255 = $calculator; $256 = ((($255)) + 88|0); $257 = HEAP32[$256>>2]|0; $258 = ($254|0)==($257|0); do { if ($258) { $259 = $calculator; $260 = ((($259)) + 52|0); $261 = HEAP32[$260>>2]|0; $262 = ((($261)) + 48|0); $263 = HEAP32[$262>>2]|0; $264 = HEAP8[$263>>0]|0; $265 = $264 << 24 >> 24; $266 = ($265|0)==(48); if ($266) { $267 = $calculator; $268 = ((($267)) + 52|0); $269 = HEAP32[$268>>2]|0; $270 = ((($269)) + 48|0); $271 = HEAP32[$270>>2]|0; $272 = ((($271)) + 1|0); $273 = HEAP8[$272>>0]|0; $274 = $273 << 24 >> 24; $275 = ($274|0)==(0); if ($275) { $279 = $calculator; $280 = ((($279)) + 52|0); $281 = HEAP32[$280>>2]|0; _Window_set_title($281,2527); break; } } $276 = $calculator; $277 = ((($276)) + 52|0); $278 = HEAP32[$277>>2]|0; _Window_append_title($278,2527); } } while(0); $282 = $0; $283 = $calculator; $284 = ((($283)) + 116|0); $285 = HEAP32[$284>>2]|0; $286 = ($282|0)==($285|0); if (!($286)) { STACKTOP = sp;return; } $287 = $calculator; $288 = ((($287)) + 52|0); $289 = HEAP32[$288>>2]|0; _Window_set_title($289,2509); STACKTOP = sp;return; } function _Calculator_new() { var $0 = 0, $1 = 0, $10 = 0, $100 = 0, $101 = 0, $102 = 0, $103 = 0, $104 = 0, $105 = 0, $106 = 0, $107 = 0, $108 = 0, $109 = 0, $11 = 0, $110 = 0, $111 = 0, $112 = 0, $113 = 0, $114 = 0, $115 = 0; var $116 = 0, $117 = 0, $118 = 0, $119 = 0, $12 = 0, $120 = 0, $121 = 0, $122 = 0, $123 = 0, $124 = 0, $125 = 0, $126 = 0, $127 = 0, $128 = 0, $129 = 0, $13 = 0, $130 = 0, $131 = 0, $132 = 0, $133 = 0; var $134 = 0, $135 = 0, $136 = 0, $137 = 0, $138 = 0, $139 = 0, $14 = 0, $140 = 0, $141 = 0, $142 = 0, $143 = 0, $144 = 0, $145 = 0, $146 = 0, $147 = 0, $148 = 0, $149 = 0, $15 = 0, $150 = 0, $151 = 0; var $152 = 0, $153 = 0, $154 = 0, $155 = 0, $156 = 0, $157 = 0, $158 = 0, $159 = 0, $16 = 0, $160 = 0, $161 = 0, $162 = 0, $163 = 0, $164 = 0, $165 = 0, $166 = 0, $167 = 0, $168 = 0, $169 = 0, $17 = 0; var $170 = 0, $171 = 0, $172 = 0, $173 = 0, $174 = 0, $175 = 0, $176 = 0, $177 = 0, $178 = 0, $179 = 0, $18 = 0, $180 = 0, $181 = 0, $182 = 0, $183 = 0, $184 = 0, $185 = 0, $186 = 0, $187 = 0, $188 = 0; var $189 = 0, $19 = 0, $190 = 0, $191 = 0, $192 = 0, $193 = 0, $194 = 0, $195 = 0, $196 = 0, $197 = 0, $198 = 0, $199 = 0, $2 = 0, $20 = 0, $200 = 0, $201 = 0, $202 = 0, $203 = 0, $204 = 0, $205 = 0; var $206 = 0, $207 = 0, $208 = 0, $209 = 0, $21 = 0, $210 = 0, $211 = 0, $212 = 0, $213 = 0, $214 = 0, $215 = 0, $216 = 0, $217 = 0, $218 = 0, $219 = 0, $22 = 0, $220 = 0, $221 = 0, $222 = 0, $223 = 0; var $224 = 0, $225 = 0, $226 = 0, $227 = 0, $228 = 0, $229 = 0, $23 = 0, $230 = 0, $231 = 0, $232 = 0, $233 = 0, $234 = 0, $235 = 0, $236 = 0, $237 = 0, $238 = 0, $239 = 0, $24 = 0, $240 = 0, $241 = 0; var $242 = 0, $25 = 0, $26 = 0, $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0; var $42 = 0, $43 = 0, $44 = 0, $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0; var $60 = 0, $61 = 0, $62 = 0, $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0; var $79 = 0, $8 = 0, $80 = 0, $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0, $9 = 0, $90 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $95 = 0, $96 = 0; var $97 = 0, $98 = 0, $99 = 0, $calculator = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = (_malloc(120)|0); $calculator = $1; $2 = ($1|0)!=(0|0); $3 = $calculator; if (!($2)) { $0 = $3; $242 = $0; STACKTOP = sp;return ($242|0); } $4 = (_Window_init($3,0,0,151,204,0,0)|0); $5 = ($4|0)!=(0); $6 = $calculator; if ($5) { _Window_set_title($6,2529); $7 = (_Button_new(8,61,30,30)|0); $8 = $calculator; $9 = ((($8)) + 80|0); HEAP32[$9>>2] = $7; $10 = $calculator; $11 = ((($10)) + 80|0); $12 = HEAP32[$11>>2]|0; _Window_set_title($12,2523); $13 = $calculator; $14 = $calculator; $15 = ((($14)) + 80|0); $16 = HEAP32[$15>>2]|0; _Window_insert_child($13,$16); $17 = (_Button_new(43,61,30,30)|0); $18 = $calculator; $19 = ((($18)) + 84|0); HEAP32[$19>>2] = $17; $20 = $calculator; $21 = ((($20)) + 84|0); $22 = HEAP32[$21>>2]|0; _Window_set_title($22,2525); $23 = $calculator; $24 = $calculator; $25 = ((($24)) + 84|0); $26 = HEAP32[$25>>2]|0; _Window_insert_child($23,$26); $27 = (_Button_new(78,61,30,30)|0); $28 = $calculator; $29 = ((($28)) + 88|0); HEAP32[$29>>2] = $27; $30 = $calculator; $31 = ((($30)) + 88|0); $32 = HEAP32[$31>>2]|0; _Window_set_title($32,2527); $33 = $calculator; $34 = $calculator; $35 = ((($34)) + 88|0); $36 = HEAP32[$35>>2]|0; _Window_insert_child($33,$36); $37 = (_Button_new(113,61,30,30)|0); $38 = $calculator; $39 = ((($38)) + 96|0); HEAP32[$39>>2] = $37; $40 = $calculator; $41 = ((($40)) + 96|0); $42 = HEAP32[$41>>2]|0; _Window_set_title($42,2540); $43 = $calculator; $44 = $calculator; $45 = ((($44)) + 96|0); $46 = HEAP32[$45>>2]|0; _Window_insert_child($43,$46); $47 = (_Button_new(8,96,30,30)|0); $48 = $calculator; $49 = ((($48)) + 68|0); HEAP32[$49>>2] = $47; $50 = $calculator; $51 = ((($50)) + 68|0); $52 = HEAP32[$51>>2]|0; _Window_set_title($52,2517); $53 = $calculator; $54 = $calculator; $55 = ((($54)) + 68|0); $56 = HEAP32[$55>>2]|0; _Window_insert_child($53,$56); $57 = (_Button_new(43,96,30,30)|0); $58 = $calculator; $59 = ((($58)) + 72|0); HEAP32[$59>>2] = $57; $60 = $calculator; $61 = ((($60)) + 72|0); $62 = HEAP32[$61>>2]|0; _Window_set_title($62,2519); $63 = $calculator; $64 = $calculator; $65 = ((($64)) + 72|0); $66 = HEAP32[$65>>2]|0; _Window_insert_child($63,$66); $67 = (_Button_new(78,96,30,30)|0); $68 = $calculator; $69 = ((($68)) + 76|0); HEAP32[$69>>2] = $67; $70 = $calculator; $71 = ((($70)) + 76|0); $72 = HEAP32[$71>>2]|0; _Window_set_title($72,2521); $73 = $calculator; $74 = $calculator; $75 = ((($74)) + 76|0); $76 = HEAP32[$75>>2]|0; _Window_insert_child($73,$76); $77 = (_Button_new(113,96,30,30)|0); $78 = $calculator; $79 = ((($78)) + 100|0); HEAP32[$79>>2] = $77; $80 = $calculator; $81 = ((($80)) + 100|0); $82 = HEAP32[$81>>2]|0; _Window_set_title($82,2542); $83 = $calculator; $84 = $calculator; $85 = ((($84)) + 100|0); $86 = HEAP32[$85>>2]|0; _Window_insert_child($83,$86); $87 = (_Button_new(8,131,30,30)|0); $88 = $calculator; $89 = ((($88)) + 56|0); HEAP32[$89>>2] = $87; $90 = $calculator; $91 = ((($90)) + 56|0); $92 = HEAP32[$91>>2]|0; _Window_set_title($92,2511); $93 = $calculator; $94 = $calculator; $95 = ((($94)) + 56|0); $96 = HEAP32[$95>>2]|0; _Window_insert_child($93,$96); $97 = (_Button_new(43,131,30,30)|0); $98 = $calculator; $99 = ((($98)) + 60|0); HEAP32[$99>>2] = $97; $100 = $calculator; $101 = ((($100)) + 60|0); $102 = HEAP32[$101>>2]|0; _Window_set_title($102,2513); $103 = $calculator; $104 = $calculator; $105 = ((($104)) + 60|0); $106 = HEAP32[$105>>2]|0; _Window_insert_child($103,$106); $107 = (_Button_new(78,131,30,30)|0); $108 = $calculator; $109 = ((($108)) + 64|0); HEAP32[$109>>2] = $107; $110 = $calculator; $111 = ((($110)) + 64|0); $112 = HEAP32[$111>>2]|0; _Window_set_title($112,2515); $113 = $calculator; $114 = $calculator; $115 = ((($114)) + 64|0); $116 = HEAP32[$115>>2]|0; _Window_insert_child($113,$116); $117 = (_Button_new(113,131,30,30)|0); $118 = $calculator; $119 = ((($118)) + 108|0); HEAP32[$119>>2] = $117; $120 = $calculator; $121 = ((($120)) + 108|0); $122 = HEAP32[$121>>2]|0; _Window_set_title($122,2544); $123 = $calculator; $124 = $calculator; $125 = ((($124)) + 108|0); $126 = HEAP32[$125>>2]|0; _Window_insert_child($123,$126); $127 = (_Button_new(8,166,30,30)|0); $128 = $calculator; $129 = ((($128)) + 116|0); HEAP32[$129>>2] = $127; $130 = $calculator; $131 = ((($130)) + 116|0); $132 = HEAP32[$131>>2]|0; _Window_set_title($132,2546); $133 = $calculator; $134 = $calculator; $135 = ((($134)) + 116|0); $136 = HEAP32[$135>>2]|0; _Window_insert_child($133,$136); $137 = (_Button_new(43,166,30,30)|0); $138 = $calculator; $139 = ((($138)) + 92|0); HEAP32[$139>>2] = $137; $140 = $calculator; $141 = ((($140)) + 92|0); $142 = HEAP32[$141>>2]|0; _Window_set_title($142,2509); $143 = $calculator; $144 = $calculator; $145 = ((($144)) + 92|0); $146 = HEAP32[$145>>2]|0; _Window_insert_child($143,$146); $147 = (_Button_new(78,166,30,30)|0); $148 = $calculator; $149 = ((($148)) + 112|0); HEAP32[$149>>2] = $147; $150 = $calculator; $151 = ((($150)) + 112|0); $152 = HEAP32[$151>>2]|0; _Window_set_title($152,2548); $153 = $calculator; $154 = $calculator; $155 = ((($154)) + 112|0); $156 = HEAP32[$155>>2]|0; _Window_insert_child($153,$156); $157 = (_Button_new(113,166,30,30)|0); $158 = $calculator; $159 = ((($158)) + 104|0); HEAP32[$159>>2] = $157; $160 = $calculator; $161 = ((($160)) + 104|0); $162 = HEAP32[$161>>2]|0; _Window_set_title($162,2550); $163 = $calculator; $164 = $calculator; $165 = ((($164)) + 104|0); $166 = HEAP32[$165>>2]|0; _Window_insert_child($163,$166); $167 = $calculator; $168 = ((($167)) + 116|0); $169 = HEAP32[$168>>2]|0; $170 = ((($169)) + 56|0); HEAP32[$170>>2] = 1; $171 = $calculator; $172 = ((($171)) + 112|0); $173 = HEAP32[$172>>2]|0; $174 = ((($173)) + 56|0); HEAP32[$174>>2] = 1; $175 = $calculator; $176 = ((($175)) + 104|0); $177 = HEAP32[$176>>2]|0; $178 = ((($177)) + 56|0); HEAP32[$178>>2] = 1; $179 = $calculator; $180 = ((($179)) + 108|0); $181 = HEAP32[$180>>2]|0; $182 = ((($181)) + 56|0); HEAP32[$182>>2] = 1; $183 = $calculator; $184 = ((($183)) + 100|0); $185 = HEAP32[$184>>2]|0; $186 = ((($185)) + 56|0); HEAP32[$186>>2] = 1; $187 = $calculator; $188 = ((($187)) + 96|0); $189 = HEAP32[$188>>2]|0; $190 = ((($189)) + 56|0); HEAP32[$190>>2] = 1; $191 = $calculator; $192 = ((($191)) + 92|0); $193 = HEAP32[$192>>2]|0; $194 = ((($193)) + 56|0); HEAP32[$194>>2] = 1; $195 = $calculator; $196 = ((($195)) + 88|0); $197 = HEAP32[$196>>2]|0; $198 = ((($197)) + 56|0); HEAP32[$198>>2] = 1; $199 = $calculator; $200 = ((($199)) + 84|0); $201 = HEAP32[$200>>2]|0; $202 = ((($201)) + 56|0); HEAP32[$202>>2] = 1; $203 = $calculator; $204 = ((($203)) + 80|0); $205 = HEAP32[$204>>2]|0; $206 = ((($205)) + 56|0); HEAP32[$206>>2] = 1; $207 = $calculator; $208 = ((($207)) + 76|0); $209 = HEAP32[$208>>2]|0; $210 = ((($209)) + 56|0); HEAP32[$210>>2] = 1; $211 = $calculator; $212 = ((($211)) + 72|0); $213 = HEAP32[$212>>2]|0; $214 = ((($213)) + 56|0); HEAP32[$214>>2] = 1; $215 = $calculator; $216 = ((($215)) + 68|0); $217 = HEAP32[$216>>2]|0; $218 = ((($217)) + 56|0); HEAP32[$218>>2] = 1; $219 = $calculator; $220 = ((($219)) + 64|0); $221 = HEAP32[$220>>2]|0; $222 = ((($221)) + 56|0); HEAP32[$222>>2] = 1; $223 = $calculator; $224 = ((($223)) + 60|0); $225 = HEAP32[$224>>2]|0; $226 = ((($225)) + 56|0); HEAP32[$226>>2] = 1; $227 = $calculator; $228 = ((($227)) + 56|0); $229 = HEAP32[$228>>2]|0; $230 = ((($229)) + 56|0); HEAP32[$230>>2] = 1; $231 = (_TextBox_new(8,36,135,20)|0); $232 = $calculator; $233 = ((($232)) + 52|0); HEAP32[$233>>2] = $231; $234 = $calculator; $235 = ((($234)) + 52|0); $236 = HEAP32[$235>>2]|0; _Window_set_title($236,2509); $237 = $calculator; $238 = $calculator; $239 = ((($238)) + 52|0); $240 = HEAP32[$239>>2]|0; _Window_insert_child($237,$240); $241 = $calculator; $0 = $241; $242 = $0; STACKTOP = sp;return ($242|0); } else { _free($6); $0 = 0; $242 = $0; STACKTOP = sp;return ($242|0); } return (0)|0; } function _TextBox_new($x,$y,$width,$height) { $x = $x|0; $y = $y|0; $width = $width|0; $height = $height|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0; var $8 = 0, $9 = 0, $text_box = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $x; $2 = $y; $3 = $width; $4 = $height; $5 = (_malloc(52)|0); $text_box = $5; $6 = ($5|0)!=(0|0); $7 = $text_box; if (!($6)) { $0 = $7; $21 = $0; STACKTOP = sp;return ($21|0); } $8 = $1; $9 = $8&65535; $10 = $2; $11 = $10&65535; $12 = $3; $13 = $12&65535; $14 = $4; $15 = $14&65535; $16 = (_Window_init($7,$9,$11,$13,$15,1,0)|0); $17 = ($16|0)!=(0); $18 = $text_box; if ($17) { $19 = ((($18)) + 40|0); HEAP32[$19>>2] = 2; $20 = $text_box; $0 = $20; $21 = $0; STACKTOP = sp;return ($21|0); } else { _free($18); $0 = 0; $21 = $0; STACKTOP = sp;return ($21|0); } return (0)|0; } function _TextBox_paint($text_box_window) { $text_box_window = $text_box_window|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $title_len = 0, label = 0; var sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $text_box_window; $1 = $0; $2 = ((($1)) + 16|0); $3 = HEAP32[$2>>2]|0; $4 = $0; $5 = ((($4)) + 8|0); $6 = HEAP16[$5>>1]|0; $7 = $6&65535; $8 = (($7) - 2)|0; $9 = $0; $10 = ((($9)) + 10|0); $11 = HEAP16[$10>>1]|0; $12 = $11&65535; $13 = (($12) - 2)|0; _Context_fill_rect($3,1,1,$8,$13,-1); $14 = $0; $15 = ((($14)) + 16|0); $16 = HEAP32[$15>>2]|0; $17 = $0; $18 = ((($17)) + 8|0); $19 = HEAP16[$18>>1]|0; $20 = $19&65535; $21 = $0; $22 = ((($21)) + 10|0); $23 = HEAP16[$22>>1]|0; $24 = $23&65535; _Context_draw_rect($16,0,0,$20,$24,-16777216); $title_len = 0; while(1) { $25 = $title_len; $26 = $0; $27 = ((($26)) + 48|0); $28 = HEAP32[$27>>2]|0; $29 = (($28) + ($25)|0); $30 = HEAP8[$29>>0]|0; $31 = ($30<<24>>24)!=(0); $32 = $title_len; if (!($31)) { break; } $33 = (($32) + 1)|0; $title_len = $33; } $34 = $32<<3; $title_len = $34; $35 = $0; $36 = ((($35)) + 48|0); $37 = HEAP32[$36>>2]|0; $38 = ($37|0)!=(0|0); if (!($38)) { STACKTOP = sp;return; } $39 = $0; $40 = ((($39)) + 16|0); $41 = HEAP32[$40>>2]|0; $42 = $0; $43 = ((($42)) + 48|0); $44 = HEAP32[$43>>2]|0; $45 = $0; $46 = ((($45)) + 8|0); $47 = HEAP16[$46>>1]|0; $48 = $47&65535; $49 = $title_len; $50 = (($48) - ($49))|0; $51 = (($50) - 6)|0; $52 = $0; $53 = ((($52)) + 10|0); $54 = HEAP16[$53>>1]|0; $55 = $54&65535; $56 = (($55|0) / 2)&-1; $57 = (($56) - 6)|0; _Context_draw_text($41,$44,$51,$57,-16777216); STACKTOP = sp;return; } function _Button_new($x,$y,$w,$h) { $x = $x|0; $y = $y|0; $w = $w|0; $h = $h|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $button = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $x; $2 = $y; $3 = $w; $4 = $h; $5 = (_malloc(60)|0); $button = $5; $6 = ($5|0)!=(0|0); $7 = $button; if (!($6)) { $0 = $7; $27 = $0; STACKTOP = sp;return ($27|0); } $8 = $1; $9 = $8&65535; $10 = $2; $11 = $10&65535; $12 = $3; $13 = $12&65535; $14 = $4; $15 = $14&65535; $16 = (_Window_init($7,$9,$11,$13,$15,1,0)|0); $17 = ($16|0)!=(0); $18 = $button; if ($17) { $19 = ((($18)) + 40|0); HEAP32[$19>>2] = 3; $20 = $button; $21 = ((($20)) + 44|0); HEAP32[$21>>2] = 4; $22 = $button; $23 = ((($22)) + 56|0); HEAP32[$23>>2] = 0; $24 = $button; $25 = ((($24)) + 52|0); HEAP8[$25>>0] = 0; $26 = $button; $0 = $26; $27 = $0; STACKTOP = sp;return ($27|0); } else { _free($18); $0 = 0; $27 = $0; STACKTOP = sp;return ($27|0); } return (0)|0; } function _Button_paint($button_window) { $button_window = $button_window|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0; var $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0; var $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0, $9 = 0, $90 = 0, $91 = 0, $border_color = 0, $button = 0, $title_len = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $button_window; $1 = $0; $button = $1; $2 = $button; $3 = ((($2)) + 52|0); $4 = HEAP8[$3>>0]|0; $5 = ($4<<24>>24)!=(0); if ($5) { $border_color = -3108752; } else { $border_color = -5526613; } $6 = $0; $7 = ((($6)) + 16|0); $8 = HEAP32[$7>>2]|0; $9 = $0; $10 = ((($9)) + 8|0); $11 = HEAP16[$10>>1]|0; $12 = $11&65535; $13 = (($12) - 1)|0; $14 = $0; $15 = ((($14)) + 10|0); $16 = HEAP16[$15>>1]|0; $17 = $16&65535; $18 = (($17) - 1)|0; _Context_fill_rect($8,1,1,$13,$18,-4473925); $19 = $0; $20 = ((($19)) + 16|0); $21 = HEAP32[$20>>2]|0; $22 = $0; $23 = ((($22)) + 8|0); $24 = HEAP16[$23>>1]|0; $25 = $24&65535; $26 = $0; $27 = ((($26)) + 10|0); $28 = HEAP16[$27>>1]|0; $29 = $28&65535; _Context_draw_rect($21,0,0,$25,$29,-16777216); $30 = $0; $31 = ((($30)) + 16|0); $32 = HEAP32[$31>>2]|0; $33 = $0; $34 = ((($33)) + 8|0); $35 = HEAP16[$34>>1]|0; $36 = $35&65535; $37 = (($36) - 6)|0; $38 = $0; $39 = ((($38)) + 10|0); $40 = HEAP16[$39>>1]|0; $41 = $40&65535; $42 = (($41) - 6)|0; $43 = $border_color; _Context_draw_rect($32,3,3,$37,$42,$43); $44 = $0; $45 = ((($44)) + 16|0); $46 = HEAP32[$45>>2]|0; $47 = $0; $48 = ((($47)) + 8|0); $49 = HEAP16[$48>>1]|0; $50 = $49&65535; $51 = (($50) - 8)|0; $52 = $0; $53 = ((($52)) + 10|0); $54 = HEAP16[$53>>1]|0; $55 = $54&65535; $56 = (($55) - 8)|0; $57 = $border_color; _Context_draw_rect($46,4,4,$51,$56,$57); $title_len = 0; while(1) { $58 = $title_len; $59 = $0; $60 = ((($59)) + 48|0); $61 = HEAP32[$60>>2]|0; $62 = (($61) + ($58)|0); $63 = HEAP8[$62>>0]|0; $64 = ($63<<24>>24)!=(0); $65 = $title_len; if (!($64)) { break; } $66 = (($65) + 1)|0; $title_len = $66; } $67 = $65<<3; $title_len = $67; $68 = $0; $69 = ((($68)) + 48|0); $70 = HEAP32[$69>>2]|0; $71 = ($70|0)!=(0|0); if (!($71)) { STACKTOP = sp;return; } $72 = $0; $73 = ((($72)) + 16|0); $74 = HEAP32[$73>>2]|0; $75 = $0; $76 = ((($75)) + 48|0); $77 = HEAP32[$76>>2]|0; $78 = $0; $79 = ((($78)) + 8|0); $80 = HEAP16[$79>>1]|0; $81 = $80&65535; $82 = (($81|0) / 2)&-1; $83 = $title_len; $84 = (($83|0) / 2)&-1; $85 = (($82) - ($84))|0; $86 = $0; $87 = ((($86)) + 10|0); $88 = HEAP16[$87>>1]|0; $89 = $88&65535; $90 = (($89|0) / 2)&-1; $91 = (($90) - 6)|0; _Context_draw_text($74,$77,$85,$91,-16777216); STACKTOP = sp;return; } function _Button_mousedown_handler($button_window,$x,$y) { $button_window = $button_window|0; $x = $x|0; $y = $y|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $button = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $button_window; $1 = $x; $2 = $y; $3 = $0; $button = $3; $4 = $button; $5 = ((($4)) + 52|0); $6 = HEAP8[$5>>0]|0; $7 = ($6<<24>>24)!=(0); $8 = $7 ^ 1; $9 = $8&1; $10 = $9&255; $11 = $button; $12 = ((($11)) + 52|0); HEAP8[$12>>0] = $10; $13 = $button; $14 = $button; $15 = ((($14)) + 10|0); $16 = HEAP16[$15>>1]|0; $17 = $16&65535; $18 = (($17) - 1)|0; $19 = $button; $20 = ((($19)) + 8|0); $21 = HEAP16[$20>>1]|0; $22 = $21&65535; $23 = (($22) - 1)|0; _Window_invalidate($13,0,0,$18,$23); $24 = $button; $25 = ((($24)) + 56|0); $26 = HEAP32[$25>>2]|0; $27 = ($26|0)!=(0|0); if (!($27)) { STACKTOP = sp;return; } $28 = $button; $29 = ((($28)) + 56|0); $30 = HEAP32[$29>>2]|0; $31 = $button; $32 = $1; $33 = $2; FUNCTION_TABLE_viii[$30 & 15]($31,$32,$33); STACKTOP = sp;return; } function _List_new() { var $0 = 0, $1 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $list = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = (_malloc(8)|0); $list = $1; $2 = ($1|0)!=(0|0); $3 = $list; if ($2) { HEAP32[$3>>2] = 0; $4 = $list; $5 = ((($4)) + 4|0); HEAP32[$5>>2] = 0; $6 = $list; $0 = $6; $7 = $0; STACKTOP = sp;return ($7|0); } else { $0 = $3; $7 = $0; STACKTOP = sp;return ($7|0); } return (0)|0; } function _List_add($list,$payload) { $list = $list|0; $payload = $payload|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $current_node = 0, $new_node = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $list; $2 = $payload; $3 = $2; $4 = (_ListNode_new($3)|0); $new_node = $4; $5 = ($4|0)!=(0|0); if (!($5)) { $0 = 0; $32 = $0; STACKTOP = sp;return ($32|0); } $6 = $1; $7 = ((($6)) + 4|0); $8 = HEAP32[$7>>2]|0; $9 = ($8|0)!=(0|0); if ($9) { $13 = $1; $14 = ((($13)) + 4|0); $15 = HEAP32[$14>>2]|0; $current_node = $15; while(1) { $16 = $current_node; $17 = ((($16)) + 8|0); $18 = HEAP32[$17>>2]|0; $19 = ($18|0)!=(0|0); if (!($19)) { break; } $20 = $current_node; $21 = ((($20)) + 8|0); $22 = HEAP32[$21>>2]|0; $current_node = $22; } $23 = $new_node; $24 = $current_node; $25 = ((($24)) + 8|0); HEAP32[$25>>2] = $23; $26 = $current_node; $27 = $new_node; $28 = ((($27)) + 4|0); HEAP32[$28>>2] = $26; } else { $10 = $new_node; $11 = $1; $12 = ((($11)) + 4|0); HEAP32[$12>>2] = $10; } $29 = $1; $30 = HEAP32[$29>>2]|0; $31 = (($30) + 1)|0; HEAP32[$29>>2] = $31; $0 = 1; $32 = $0; STACKTOP = sp;return ($32|0); } function _List_get_at($list,$index) { $list = $list|0; $index = $index|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $current_index = 0, $current_node = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $list; $2 = $index; $3 = $1; $4 = HEAP32[$3>>2]|0; $5 = ($4|0)==(0); if (!($5)) { $6 = $2; $7 = $1; $8 = HEAP32[$7>>2]|0; $9 = ($6>>>0)>=($8>>>0); if (!($9)) { $10 = $1; $11 = ((($10)) + 4|0); $12 = HEAP32[$11>>2]|0; $current_node = $12; $current_index = 0; while(1) { $13 = $current_index; $14 = $2; $15 = ($13>>>0)<($14>>>0); $16 = $current_node; $17 = ($16|0)!=(0|0); $18 = $15 ? $17 : 0; $19 = $current_node; if (!($18)) { break; } $20 = ((($19)) + 8|0); $21 = HEAP32[$20>>2]|0; $current_node = $21; $22 = $current_index; $23 = (($22) + 1)|0; $current_index = $23; } $24 = ($19|0)!=(0|0); if ($24) { $25 = $current_node; $26 = HEAP32[$25>>2]|0; $27 = $26; } else { $27 = 0; } $0 = $27; $28 = $0; STACKTOP = sp;return ($28|0); } } $0 = 0; $28 = $0; STACKTOP = sp;return ($28|0); } function _List_remove_at($list,$index) { $list = $list|0; $index = $index|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $7 = 0; var $8 = 0, $9 = 0, $current_index = 0, $current_node = 0, $payload = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $list; $2 = $index; $3 = $1; $4 = HEAP32[$3>>2]|0; $5 = ($4|0)==(0); if (!($5)) { $6 = $2; $7 = $1; $8 = HEAP32[$7>>2]|0; $9 = ($6>>>0)>=($8>>>0); if (!($9)) { $10 = $1; $11 = ((($10)) + 4|0); $12 = HEAP32[$11>>2]|0; $current_node = $12; $current_index = 0; while(1) { $13 = $current_index; $14 = $2; $15 = ($13>>>0)<($14>>>0); $16 = $current_node; $17 = ($16|0)!=(0|0); $18 = $15 ? $17 : 0; $19 = $current_node; if (!($18)) { break; } $20 = ((($19)) + 8|0); $21 = HEAP32[$20>>2]|0; $current_node = $21; $22 = $current_index; $23 = (($22) + 1)|0; $current_index = $23; } $24 = ($19|0)!=(0|0); if (!($24)) { $0 = 0; $61 = $0; STACKTOP = sp;return ($61|0); } $25 = $current_node; $26 = HEAP32[$25>>2]|0; $payload = $26; $27 = $current_node; $28 = ((($27)) + 4|0); $29 = HEAP32[$28>>2]|0; $30 = ($29|0)!=(0|0); if ($30) { $31 = $current_node; $32 = ((($31)) + 8|0); $33 = HEAP32[$32>>2]|0; $34 = $current_node; $35 = ((($34)) + 4|0); $36 = HEAP32[$35>>2]|0; $37 = ((($36)) + 8|0); HEAP32[$37>>2] = $33; } $38 = $current_node; $39 = ((($38)) + 8|0); $40 = HEAP32[$39>>2]|0; $41 = ($40|0)!=(0|0); if ($41) { $42 = $current_node; $43 = ((($42)) + 4|0); $44 = HEAP32[$43>>2]|0; $45 = $current_node; $46 = ((($45)) + 8|0); $47 = HEAP32[$46>>2]|0; $48 = ((($47)) + 4|0); HEAP32[$48>>2] = $44; } $49 = $2; $50 = ($49|0)==(0); if ($50) { $51 = $current_node; $52 = ((($51)) + 8|0); $53 = HEAP32[$52>>2]|0; $54 = $1; $55 = ((($54)) + 4|0); HEAP32[$55>>2] = $53; } $56 = $current_node; _free($56); $57 = $1; $58 = HEAP32[$57>>2]|0; $59 = (($58) + -1)|0; HEAP32[$57>>2] = $59; $60 = $payload; $0 = $60; $61 = $0; STACKTOP = sp;return ($61|0); } } $0 = 0; $61 = $0; STACKTOP = sp;return ($61|0); } function _Context_new($width,$height,$buffer) { $width = $width|0; $height = $height|0; $buffer = $buffer|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $3 = 0, $4 = 0, $5 = 0; var $6 = 0, $7 = 0, $8 = 0, $9 = 0, $context = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $width; $2 = $height; $3 = $buffer; $4 = (_malloc(24)|0); $context = $4; $5 = ($4|0)!=(0|0); if (!($5)) { $6 = $context; $0 = $6; $23 = $0; STACKTOP = sp;return ($23|0); } $7 = (_List_new()|0); $8 = $context; $9 = ((($8)) + 16|0); HEAP32[$9>>2] = $7; $10 = ($7|0)!=(0|0); if ($10) { $12 = $1; $13 = $context; $14 = ((($13)) + 4|0); HEAP16[$14>>1] = $12; $15 = $2; $16 = $context; $17 = ((($16)) + 6|0); HEAP16[$17>>1] = $15; $18 = $3; $19 = $context; HEAP32[$19>>2] = $18; $20 = $context; $21 = ((($20)) + 20|0); HEAP8[$21>>0] = 0; $22 = $context; $0 = $22; $23 = $0; STACKTOP = sp;return ($23|0); } else { $11 = $context; _free($11); $0 = 0; $23 = $0; STACKTOP = sp;return ($23|0); } return (0)|0; } function _Context_clipped_rect($context,$x,$y,$width,$height,$clip_area,$color) { $context = $context|0; $x = $x|0; $y = $y|0; $width = $width|0; $height = $height|0; $clip_area = $clip_area|0; $color = $color|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0; var $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0; var $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0, $9 = 0, $cur_x = 0, $max_x = 0, $max_y = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 48|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $context; $1 = $x; $2 = $y; $3 = $width; $4 = $height; $5 = $clip_area; $6 = $color; $7 = $1; $8 = $3; $9 = (($7) + ($8))|0; $max_x = $9; $10 = $2; $11 = $4; $12 = (($10) + ($11))|0; $max_y = $12; $13 = $0; $14 = ((($13)) + 8|0); $15 = HEAP32[$14>>2]|0; $16 = $1; $17 = (($16) + ($15))|0; $1 = $17; $18 = $0; $19 = ((($18)) + 12|0); $20 = HEAP32[$19>>2]|0; $21 = $2; $22 = (($21) + ($20))|0; $2 = $22; $23 = $0; $24 = ((($23)) + 8|0); $25 = HEAP32[$24>>2]|0; $26 = $max_x; $27 = (($26) + ($25))|0; $max_x = $27; $28 = $0; $29 = ((($28)) + 12|0); $30 = HEAP32[$29>>2]|0; $31 = $max_y; $32 = (($31) + ($30))|0; $max_y = $32; $33 = $1; $34 = $5; $35 = ((($34)) + 4|0); $36 = HEAP32[$35>>2]|0; $37 = ($33|0)<($36|0); if ($37) { $38 = $5; $39 = ((($38)) + 4|0); $40 = HEAP32[$39>>2]|0; $1 = $40; } $41 = $2; $42 = $5; $43 = HEAP32[$42>>2]|0; $44 = ($41|0)<($43|0); if ($44) { $45 = $5; $46 = HEAP32[$45>>2]|0; $2 = $46; } $47 = $max_x; $48 = $5; $49 = ((($48)) + 12|0); $50 = HEAP32[$49>>2]|0; $51 = (($50) + 1)|0; $52 = ($47|0)>($51|0); if ($52) { $53 = $5; $54 = ((($53)) + 12|0); $55 = HEAP32[$54>>2]|0; $56 = (($55) + 1)|0; $max_x = $56; } $57 = $max_y; $58 = $5; $59 = ((($58)) + 8|0); $60 = HEAP32[$59>>2]|0; $61 = (($60) + 1)|0; $62 = ($57|0)>($61|0); if ($62) { $63 = $5; $64 = ((($63)) + 8|0); $65 = HEAP32[$64>>2]|0; $66 = (($65) + 1)|0; $max_y = $66; } while(1) { $67 = $2; $68 = $max_y; $69 = ($67|0)<($68|0); if (!($69)) { break; } $70 = $1; $cur_x = $70; while(1) { $71 = $cur_x; $72 = $max_x; $73 = ($71|0)<($72|0); if (!($73)) { break; } $74 = $6; $75 = $2; $76 = $0; $77 = ((($76)) + 4|0); $78 = HEAP16[$77>>1]|0; $79 = $78&65535; $80 = Math_imul($75, $79)|0; $81 = $cur_x; $82 = (($80) + ($81))|0; $83 = $0; $84 = HEAP32[$83>>2]|0; $85 = (($84) + ($82<<2)|0); HEAP32[$85>>2] = $74; $86 = $cur_x; $87 = (($86) + 1)|0; $cur_x = $87; } $88 = $2; $89 = (($88) + 1)|0; $2 = $89; } STACKTOP = sp;return; } function _Context_fill_rect($context,$x,$y,$width,$height,$color) { $context = $context|0; $x = $x|0; $y = $y|0; $width = $width|0; $height = $height|0; $color = $color|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0; var $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0; var $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0, $9 = 0, $clip_area = 0, $i = 0, $max_x = 0, $max_y = 0, $screen_area = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 64|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $screen_area = sp; $0 = $context; $1 = $x; $2 = $y; $3 = $width; $4 = $height; $5 = $color; $6 = $1; $7 = $3; $8 = (($6) + ($7))|0; $max_x = $8; $9 = $2; $10 = $4; $11 = (($9) + ($10))|0; $max_y = $11; $12 = $max_x; $13 = $0; $14 = ((($13)) + 4|0); $15 = HEAP16[$14>>1]|0; $16 = $15&65535; $17 = ($12|0)>($16|0); if ($17) { $18 = $0; $19 = ((($18)) + 4|0); $20 = HEAP16[$19>>1]|0; $21 = $20&65535; $max_x = $21; } $22 = $max_y; $23 = $0; $24 = ((($23)) + 6|0); $25 = HEAP16[$24>>1]|0; $26 = $25&65535; $27 = ($22|0)>($26|0); if ($27) { $28 = $0; $29 = ((($28)) + 6|0); $30 = HEAP16[$29>>1]|0; $31 = $30&65535; $max_y = $31; } $32 = $1; $33 = ($32|0)<(0); if ($33) { $1 = 0; } $34 = $2; $35 = ($34|0)<(0); if ($35) { $2 = 0; } $36 = $max_x; $37 = $1; $38 = (($36) - ($37))|0; $3 = $38; $39 = $max_y; $40 = $2; $41 = (($39) - ($40))|0; $4 = $41; $42 = $0; $43 = ((($42)) + 16|0); $44 = HEAP32[$43>>2]|0; $45 = HEAP32[$44>>2]|0; $46 = ($45|0)!=(0); if ($46) { $i = 0; while(1) { $47 = $i; $48 = $0; $49 = ((($48)) + 16|0); $50 = HEAP32[$49>>2]|0; $51 = HEAP32[$50>>2]|0; $52 = ($47>>>0)<($51>>>0); if (!($52)) { break; } $53 = $0; $54 = ((($53)) + 16|0); $55 = HEAP32[$54>>2]|0; $56 = $i; $57 = (_List_get_at($55,$56)|0); $clip_area = $57; $58 = $0; $59 = $1; $60 = $2; $61 = $3; $62 = $4; $63 = $clip_area; $64 = $5; _Context_clipped_rect($58,$59,$60,$61,$62,$63,$64); $65 = $i; $66 = (($65) + 1)|0; $i = $66; } STACKTOP = sp;return; } else { $67 = $0; $68 = ((($67)) + 20|0); $69 = HEAP8[$68>>0]|0; $70 = ($69<<24>>24)!=(0); if ($70) { STACKTOP = sp;return; } HEAP32[$screen_area>>2] = 0; $71 = ((($screen_area)) + 4|0); HEAP32[$71>>2] = 0; $72 = $0; $73 = ((($72)) + 6|0); $74 = HEAP16[$73>>1]|0; $75 = $74&65535; $76 = (($75) - 1)|0; $77 = ((($screen_area)) + 8|0); HEAP32[$77>>2] = $76; $78 = $0; $79 = ((($78)) + 4|0); $80 = HEAP16[$79>>1]|0; $81 = $80&65535; $82 = (($81) - 1)|0; $83 = ((($screen_area)) + 12|0); HEAP32[$83>>2] = $82; $84 = $0; $85 = $1; $86 = $2; $87 = $3; $88 = $4; $89 = $5; _Context_clipped_rect($84,$85,$86,$87,$88,$screen_area,$89); STACKTOP = sp;return; } } function _Context_horizontal_line($context,$x,$y,$length,$color) { $context = $context|0; $x = $x|0; $y = $y|0; $length = $length|0; $color = $color|0; var $0 = 0, $1 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $context; $1 = $x; $2 = $y; $3 = $length; $4 = $color; $5 = $0; $6 = $1; $7 = $2; $8 = $3; $9 = $4; _Context_fill_rect($5,$6,$7,$8,1,$9); STACKTOP = sp;return; } function _Context_vertical_line($context,$x,$y,$length,$color) { $context = $context|0; $x = $x|0; $y = $y|0; $length = $length|0; $color = $color|0; var $0 = 0, $1 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $context; $1 = $x; $2 = $y; $3 = $length; $4 = $color; $5 = $0; $6 = $1; $7 = $2; $8 = $3; $9 = $4; _Context_fill_rect($5,$6,$7,1,$8,$9); STACKTOP = sp;return; } function _Context_draw_rect($context,$x,$y,$width,$height,$color) { $context = $context|0; $x = $x|0; $y = $y|0; $width = $width|0; $height = $height|0; $color = $color|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $context; $1 = $x; $2 = $y; $3 = $width; $4 = $height; $5 = $color; $6 = $0; $7 = $1; $8 = $2; $9 = $3; $10 = $5; _Context_horizontal_line($6,$7,$8,$9,$10); $11 = $0; $12 = $1; $13 = $2; $14 = (($13) + 1)|0; $15 = $4; $16 = (($15) - 2)|0; $17 = $5; _Context_vertical_line($11,$12,$14,$16,$17); $18 = $0; $19 = $1; $20 = $2; $21 = $4; $22 = (($20) + ($21))|0; $23 = (($22) - 1)|0; $24 = $3; $25 = $5; _Context_horizontal_line($18,$19,$23,$24,$25); $26 = $0; $27 = $1; $28 = $3; $29 = (($27) + ($28))|0; $30 = (($29) - 1)|0; $31 = $2; $32 = (($31) + 1)|0; $33 = $4; $34 = (($33) - 2)|0; $35 = $5; _Context_vertical_line($26,$30,$32,$34,$35); STACKTOP = sp;return; } function _Context_intersect_clip_rect($context,$rect) { $context = $context|0; $rect = $rect|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $current_rect = 0; var $i = 0, $intersect_rect = 0, $output_rects = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $context; $1 = $rect; $2 = $0; $3 = ((($2)) + 20|0); HEAP8[$3>>0] = 1; $4 = (_List_new()|0); $output_rects = $4; $5 = ($4|0)!=(0|0); if (!($5)) { STACKTOP = sp;return; } $i = 0; while(1) { $6 = $i; $7 = $0; $8 = ((($7)) + 16|0); $9 = HEAP32[$8>>2]|0; $10 = HEAP32[$9>>2]|0; $11 = ($6>>>0)<($10>>>0); if (!($11)) { break; } $12 = $0; $13 = ((($12)) + 16|0); $14 = HEAP32[$13>>2]|0; $15 = $i; $16 = (_List_get_at($14,$15)|0); $current_rect = $16; $17 = $current_rect; $18 = $1; $19 = (_Rect_intersect($17,$18)|0); $intersect_rect = $19; $20 = $intersect_rect; $21 = ($20|0)!=(0|0); if ($21) { $22 = $output_rects; $23 = $intersect_rect; (_List_add($22,$23)|0); } $24 = $i; $25 = (($24) + 1)|0; $i = $25; } while(1) { $26 = $0; $27 = ((($26)) + 16|0); $28 = HEAP32[$27>>2]|0; $29 = HEAP32[$28>>2]|0; $30 = ($29|0)!=(0); $31 = $0; $32 = ((($31)) + 16|0); $33 = HEAP32[$32>>2]|0; if (!($30)) { break; } $34 = (_List_remove_at($33,0)|0); _free($34); } _free($33); $35 = $output_rects; $36 = $0; $37 = ((($36)) + 16|0); HEAP32[$37>>2] = $35; $38 = $1; _free($38); STACKTOP = sp;return; } function _Context_subtract_clip_rect($context,$subtracted_rect) { $context = $context|0; $subtracted_rect = $subtracted_rect|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0; var $cur_rect = 0, $i = 0, $split_rects = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $context; $1 = $subtracted_rect; $2 = $0; $3 = ((($2)) + 20|0); HEAP8[$3>>0] = 1; $i = 0; while(1) { $4 = $i; $5 = $0; $6 = ((($5)) + 16|0); $7 = HEAP32[$6>>2]|0; $8 = HEAP32[$7>>2]|0; $9 = ($4>>>0)<($8>>>0); if (!($9)) { break; } $10 = $0; $11 = ((($10)) + 16|0); $12 = HEAP32[$11>>2]|0; $13 = $i; $14 = (_List_get_at($12,$13)|0); $cur_rect = $14; $15 = $cur_rect; $16 = ((($15)) + 4|0); $17 = HEAP32[$16>>2]|0; $18 = $1; $19 = ((($18)) + 12|0); $20 = HEAP32[$19>>2]|0; $21 = ($17|0)<=($20|0); if ($21) { $22 = $cur_rect; $23 = ((($22)) + 12|0); $24 = HEAP32[$23>>2]|0; $25 = $1; $26 = ((($25)) + 4|0); $27 = HEAP32[$26>>2]|0; $28 = ($24|0)>=($27|0); if ($28) { $29 = $cur_rect; $30 = HEAP32[$29>>2]|0; $31 = $1; $32 = ((($31)) + 8|0); $33 = HEAP32[$32>>2]|0; $34 = ($30|0)<=($33|0); if ($34) { $35 = $cur_rect; $36 = ((($35)) + 8|0); $37 = HEAP32[$36>>2]|0; $38 = $1; $39 = HEAP32[$38>>2]|0; $40 = ($37|0)>=($39|0); if ($40) { $43 = $0; $44 = ((($43)) + 16|0); $45 = HEAP32[$44>>2]|0; $46 = $i; (_List_remove_at($45,$46)|0); $47 = $cur_rect; $48 = $1; $49 = (_Rect_split($47,$48)|0); $split_rects = $49; $50 = $cur_rect; _free($50); while(1) { $51 = $split_rects; $52 = HEAP32[$51>>2]|0; $53 = ($52|0)!=(0); $54 = $split_rects; if (!($53)) { break; } $55 = (_List_remove_at($54,0)|0); $cur_rect = $55; $56 = $0; $57 = ((($56)) + 16|0); $58 = HEAP32[$57>>2]|0; $59 = $cur_rect; (_List_add($58,$59)|0); } _free($54); $i = 0; continue; } } } } $41 = $i; $42 = (($41) + 1)|0; $i = $42; } STACKTOP = sp;return; } function _Context_add_clip_rect($context,$added_rect) { $context = $context|0; $added_rect = $added_rect|0; var $0 = 0, $1 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $context; $1 = $added_rect; $2 = $0; $3 = $1; _Context_subtract_clip_rect($2,$3); $4 = $0; $5 = ((($4)) + 16|0); $6 = HEAP32[$5>>2]|0; $7 = $1; (_List_add($6,$7)|0); STACKTOP = sp;return; } function _Context_clear_clip_rects($context) { $context = $context|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $cur_rect = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $context; $1 = $0; $2 = ((($1)) + 20|0); HEAP8[$2>>0] = 0; while(1) { $3 = $0; $4 = ((($3)) + 16|0); $5 = HEAP32[$4>>2]|0; $6 = HEAP32[$5>>2]|0; $7 = ($6|0)!=(0); if (!($7)) { break; } $8 = $0; $9 = ((($8)) + 16|0); $10 = HEAP32[$9>>2]|0; $11 = (_List_remove_at($10,0)|0); $cur_rect = $11; $12 = $cur_rect; _free($12); } STACKTOP = sp;return; } function _Context_draw_char_clipped($context,$character,$x,$y,$color,$bound_rect) { $context = $context|0; $character = $character|0; $x = $x|0; $y = $y|0; $color = $color|0; $bound_rect = $bound_rect|0; var $0 = 0, $1 = 0, $10 = 0, $100 = 0, $101 = 0, $102 = 0, $103 = 0, $104 = 0, $105 = 0, $106 = 0, $107 = 0, $108 = 0, $109 = 0, $11 = 0, $110 = 0, $111 = 0, $112 = 0, $113 = 0, $114 = 0, $115 = 0; var $116 = 0, $117 = 0, $118 = 0, $119 = 0, $12 = 0, $120 = 0, $121 = 0, $122 = 0, $123 = 0, $124 = 0, $125 = 0, $126 = 0, $127 = 0, $128 = 0, $129 = 0, $13 = 0, $130 = 0, $14 = 0, $15 = 0, $16 = 0; var $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0, $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0; var $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0, $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0; var $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0, $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0; var $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0, $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0; var $9 = 0, $90 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $95 = 0, $96 = 0, $97 = 0, $98 = 0, $99 = 0, $count_x = 0, $count_y = 0, $font_x = 0, $font_y = 0, $off_x = 0, $off_y = 0, $shift_line = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 48|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $context; $1 = $character; $2 = $x; $3 = $y; $4 = $color; $5 = $bound_rect; $off_x = 0; $off_y = 0; $count_x = 8; $count_y = 12; $6 = $0; $7 = ((($6)) + 8|0); $8 = HEAP32[$7>>2]|0; $9 = $2; $10 = (($9) + ($8))|0; $2 = $10; $11 = $0; $12 = ((($11)) + 12|0); $13 = HEAP32[$12>>2]|0; $14 = $3; $15 = (($14) + ($13))|0; $3 = $15; $16 = $1; $17 = $16 << 24 >> 24; $18 = $17 & 127; $19 = $18&255; $1 = $19; $20 = $2; $21 = $5; $22 = ((($21)) + 12|0); $23 = HEAP32[$22>>2]|0; $24 = ($20|0)>($23|0); if ($24) { STACKTOP = sp;return; } $25 = $2; $26 = (($25) + 8)|0; $27 = $5; $28 = ((($27)) + 4|0); $29 = HEAP32[$28>>2]|0; $30 = ($26|0)<=($29|0); if ($30) { STACKTOP = sp;return; } $31 = $3; $32 = $5; $33 = ((($32)) + 8|0); $34 = HEAP32[$33>>2]|0; $35 = ($31|0)>($34|0); if ($35) { STACKTOP = sp;return; } $36 = $3; $37 = (($36) + 12)|0; $38 = $5; $39 = HEAP32[$38>>2]|0; $40 = ($37|0)<=($39|0); if ($40) { STACKTOP = sp;return; } $41 = $2; $42 = $5; $43 = ((($42)) + 4|0); $44 = HEAP32[$43>>2]|0; $45 = ($41|0)<($44|0); if ($45) { $46 = $5; $47 = ((($46)) + 4|0); $48 = HEAP32[$47>>2]|0; $49 = $2; $50 = (($48) - ($49))|0; $off_x = $50; } $51 = $2; $52 = (($51) + 8)|0; $53 = $5; $54 = ((($53)) + 12|0); $55 = HEAP32[$54>>2]|0; $56 = ($52|0)>($55|0); if ($56) { $57 = $5; $58 = ((($57)) + 12|0); $59 = HEAP32[$58>>2]|0; $60 = $2; $61 = (($59) - ($60))|0; $62 = (($61) + 1)|0; $count_x = $62; } $63 = $3; $64 = $5; $65 = HEAP32[$64>>2]|0; $66 = ($63|0)<($65|0); if ($66) { $67 = $5; $68 = HEAP32[$67>>2]|0; $69 = $3; $70 = (($68) - ($69))|0; $off_y = $70; } $71 = $3; $72 = (($71) + 12)|0; $73 = $5; $74 = ((($73)) + 8|0); $75 = HEAP32[$74>>2]|0; $76 = ($72|0)>($75|0); if ($76) { $77 = $5; $78 = ((($77)) + 8|0); $79 = HEAP32[$78>>2]|0; $80 = $3; $81 = (($79) - ($80))|0; $82 = (($81) + 1)|0; $count_y = $82; } $83 = $off_y; $font_y = $83; while(1) { $84 = $font_y; $85 = $count_y; $86 = ($84|0)<($85|0); if (!($86)) { break; } $87 = $font_y; $88 = $87<<7; $89 = $1; $90 = $89 << 24 >> 24; $91 = (($88) + ($90))|0; $92 = (2552 + ($91)|0); $93 = HEAP8[$92>>0]|0; $shift_line = $93; $94 = $off_x; $95 = $shift_line; $96 = $95&255; $97 = $96 << $94; $98 = $97&255; $shift_line = $98; $99 = $off_x; $font_x = $99; while(1) { $100 = $font_x; $101 = $count_x; $102 = ($100|0)<($101|0); if (!($102)) { break; } $103 = $shift_line; $104 = $103&255; $105 = $104 & 128; $106 = ($105|0)!=(0); if ($106) { $107 = $4; $108 = $font_y; $109 = $3; $110 = (($108) + ($109))|0; $111 = $0; $112 = ((($111)) + 4|0); $113 = HEAP16[$112>>1]|0; $114 = $113&65535; $115 = Math_imul($110, $114)|0; $116 = $font_x; $117 = $2; $118 = (($116) + ($117))|0; $119 = (($115) + ($118))|0; $120 = $0; $121 = HEAP32[$120>>2]|0; $122 = (($121) + ($119<<2)|0); HEAP32[$122>>2] = $107; } $123 = $shift_line; $124 = $123&255; $125 = $124 << 1; $126 = $125&255; $shift_line = $126; $127 = $font_x; $128 = (($127) + 1)|0; $font_x = $128; } $129 = $font_y; $130 = (($129) + 1)|0; $font_y = $130; } STACKTOP = sp;return; } function _Context_draw_char($context,$character,$x,$y,$color) { $context = $context|0; $character = $character|0; $x = $x|0; $y = $y|0; $color = $color|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $clip_area = 0, $i = 0, $screen_area = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 48|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $screen_area = sp; $0 = $context; $1 = $character; $2 = $x; $3 = $y; $4 = $color; $5 = $0; $6 = ((($5)) + 16|0); $7 = HEAP32[$6>>2]|0; $8 = HEAP32[$7>>2]|0; $9 = ($8|0)!=(0); if ($9) { $i = 0; while(1) { $10 = $i; $11 = $0; $12 = ((($11)) + 16|0); $13 = HEAP32[$12>>2]|0; $14 = HEAP32[$13>>2]|0; $15 = ($10>>>0)<($14>>>0); if (!($15)) { break; } $16 = $0; $17 = ((($16)) + 16|0); $18 = HEAP32[$17>>2]|0; $19 = $i; $20 = (_List_get_at($18,$19)|0); $clip_area = $20; $21 = $0; $22 = $1; $23 = $2; $24 = $3; $25 = $4; $26 = $clip_area; _Context_draw_char_clipped($21,$22,$23,$24,$25,$26); $27 = $i; $28 = (($27) + 1)|0; $i = $28; } STACKTOP = sp;return; } else { $29 = $0; $30 = ((($29)) + 20|0); $31 = HEAP8[$30>>0]|0; $32 = ($31<<24>>24)!=(0); if ($32) { STACKTOP = sp;return; } HEAP32[$screen_area>>2] = 0; $33 = ((($screen_area)) + 4|0); HEAP32[$33>>2] = 0; $34 = $0; $35 = ((($34)) + 6|0); $36 = HEAP16[$35>>1]|0; $37 = $36&65535; $38 = (($37) - 1)|0; $39 = ((($screen_area)) + 8|0); HEAP32[$39>>2] = $38; $40 = $0; $41 = ((($40)) + 4|0); $42 = HEAP16[$41>>1]|0; $43 = $42&65535; $44 = (($43) - 1)|0; $45 = ((($screen_area)) + 12|0); HEAP32[$45>>2] = $44; $46 = $0; $47 = $1; $48 = $2; $49 = $3; $50 = $4; $51 = $clip_area; _Context_draw_char_clipped($46,$47,$48,$49,$50,$51); STACKTOP = sp;return; } } function _Context_draw_text($context,$string,$x,$y,$color) { $context = $context|0; $string = $string|0; $x = $x|0; $y = $y|0; $color = $color|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $context; $1 = $string; $2 = $x; $3 = $y; $4 = $color; while(1) { $5 = $1; $6 = HEAP8[$5>>0]|0; $7 = ($6<<24>>24)!=(0); if (!($7)) { break; } $8 = $0; $9 = $1; $10 = ((($9)) + 1|0); $1 = $10; $11 = HEAP8[$9>>0]|0; $12 = $2; $13 = $3; $14 = $4; _Context_draw_char($8,$11,$12,$13,$14); $15 = $2; $16 = (($15) + 8)|0; $2 = $16; } STACKTOP = sp;return; } function _Window_init($window,$x,$y,$width,$height,$flags,$context) { $window = $window|0; $x = $x|0; $y = $y|0; $width = $width|0; $height = $height|0; $flags = $flags|0; $context = $context|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $window; $2 = $x; $3 = $y; $4 = $width; $5 = $height; $6 = $flags; $7 = $context; $8 = (_List_new()|0); $9 = $1; $10 = ((($9)) + 28|0); HEAP32[$10>>2] = $8; $11 = ($8|0)!=(0|0); if ($11) { $12 = $2; $13 = $1; $14 = ((($13)) + 4|0); HEAP16[$14>>1] = $12; $15 = $3; $16 = $1; $17 = ((($16)) + 6|0); HEAP16[$17>>1] = $15; $18 = $4; $19 = $1; $20 = ((($19)) + 8|0); HEAP16[$20>>1] = $18; $21 = $5; $22 = $1; $23 = ((($22)) + 10|0); HEAP16[$23>>1] = $21; $24 = $7; $25 = $1; $26 = ((($25)) + 16|0); HEAP32[$26>>2] = $24; $27 = $6; $28 = $1; $29 = ((($28)) + 12|0); HEAP16[$29>>1] = $27; $30 = $1; HEAP32[$30>>2] = 0; $31 = $1; $32 = ((($31)) + 20|0); HEAP32[$32>>2] = 0; $33 = $1; $34 = ((($33)) + 32|0); HEAP16[$34>>1] = 0; $35 = $1; $36 = ((($35)) + 34|0); HEAP16[$36>>1] = 0; $37 = $1; $38 = ((($37)) + 36|0); HEAP8[$38>>0] = 0; $39 = $1; $40 = ((($39)) + 40|0); HEAP32[$40>>2] = 5; $41 = $1; $42 = ((($41)) + 44|0); HEAP32[$42>>2] = 6; $43 = $1; $44 = ((($43)) + 24|0); HEAP32[$44>>2] = 0; $45 = $1; $46 = ((($45)) + 48|0); HEAP32[$46>>2] = 0; $0 = 1; $47 = $0; STACKTOP = sp;return ($47|0); } else { $0 = 0; $47 = $0; STACKTOP = sp;return ($47|0); } return (0)|0; } function _Window_paint_handler($window) { $window = $window|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $window; $1 = $0; $2 = ((($1)) + 16|0); $3 = HEAP32[$2>>2]|0; $4 = $0; $5 = ((($4)) + 8|0); $6 = HEAP16[$5>>1]|0; $7 = $6&65535; $8 = $0; $9 = ((($8)) + 10|0); $10 = HEAP16[$9>>1]|0; $11 = $10&65535; _Context_fill_rect($3,0,0,$7,$11,-4473925); STACKTOP = sp;return; } function _Window_mousedown_handler($window,$x,$y) { $window = $window|0; $x = $x|0; $y = $y|0; var $0 = 0, $1 = 0, $2 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $window; $1 = $x; $2 = $y; STACKTOP = sp;return; } function _Window_screen_x($window) { $window = $window|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $window; $2 = $1; $3 = HEAP32[$2>>2]|0; $4 = ($3|0)!=(0|0); $5 = $1; $6 = ((($5)) + 4|0); $7 = HEAP16[$6>>1]|0; $8 = $7 << 16 >> 16; if ($4) { $9 = $1; $10 = HEAP32[$9>>2]|0; $11 = (_Window_screen_x($10)|0); $12 = (($8) + ($11))|0; $0 = $12; $13 = $0; STACKTOP = sp;return ($13|0); } else { $0 = $8; $13 = $0; STACKTOP = sp;return ($13|0); } return (0)|0; } function _Window_screen_y($window) { $window = $window|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $window; $2 = $1; $3 = HEAP32[$2>>2]|0; $4 = ($3|0)!=(0|0); $5 = $1; $6 = ((($5)) + 6|0); $7 = HEAP16[$6>>1]|0; $8 = $7 << 16 >> 16; if ($4) { $9 = $1; $10 = HEAP32[$9>>2]|0; $11 = (_Window_screen_y($10)|0); $12 = (($8) + ($11))|0; $0 = $12; $13 = $0; STACKTOP = sp;return ($13|0); } else { $0 = $8; $13 = $0; STACKTOP = sp;return ($13|0); } return (0)|0; } function _Window_draw_border($window) { $window = $window|0; var $0 = 0, $1 = 0, $10 = 0, $100 = 0, $101 = 0, $102 = 0, $103 = 0, $104 = 0, $105 = 0, $106 = 0, $107 = 0, $108 = 0, $109 = 0, $11 = 0, $110 = 0, $111 = 0, $112 = 0, $113 = 0, $114 = 0, $115 = 0; var $116 = 0, $117 = 0, $118 = 0, $119 = 0, $12 = 0, $120 = 0, $121 = 0, $122 = 0, $123 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0; var $23 = 0, $24 = 0, $25 = 0, $26 = 0, $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0; var $41 = 0, $42 = 0, $43 = 0, $44 = 0, $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0; var $6 = 0, $60 = 0, $61 = 0, $62 = 0, $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0; var $78 = 0, $79 = 0, $8 = 0, $80 = 0, $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0, $9 = 0, $90 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $95 = 0; var $96 = 0, $97 = 0, $98 = 0, $99 = 0, $screen_x = 0, $screen_y = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $window; $1 = $0; $2 = (_Window_screen_x($1)|0); $screen_x = $2; $3 = $0; $4 = (_Window_screen_y($3)|0); $screen_y = $4; $5 = $0; $6 = ((($5)) + 16|0); $7 = HEAP32[$6>>2]|0; $8 = $screen_x; $9 = $screen_y; $10 = $0; $11 = ((($10)) + 8|0); $12 = HEAP16[$11>>1]|0; $13 = $12&65535; $14 = $0; $15 = ((($14)) + 10|0); $16 = HEAP16[$15>>1]|0; $17 = $16&65535; _Context_draw_rect($7,$8,$9,$13,$17,-16777216); $18 = $0; $19 = ((($18)) + 16|0); $20 = HEAP32[$19>>2]|0; $21 = $screen_x; $22 = (($21) + 1)|0; $23 = $screen_y; $24 = (($23) + 1)|0; $25 = $0; $26 = ((($25)) + 8|0); $27 = HEAP16[$26>>1]|0; $28 = $27&65535; $29 = (($28) - 2)|0; $30 = $0; $31 = ((($30)) + 10|0); $32 = HEAP16[$31>>1]|0; $33 = $32&65535; $34 = (($33) - 2)|0; _Context_draw_rect($20,$22,$24,$29,$34,-16777216); $35 = $0; $36 = ((($35)) + 16|0); $37 = HEAP32[$36>>2]|0; $38 = $screen_x; $39 = (($38) + 2)|0; $40 = $screen_y; $41 = (($40) + 2)|0; $42 = $0; $43 = ((($42)) + 8|0); $44 = HEAP16[$43>>1]|0; $45 = $44&65535; $46 = (($45) - 4)|0; $47 = $0; $48 = ((($47)) + 10|0); $49 = HEAP16[$48>>1]|0; $50 = $49&65535; $51 = (($50) - 4)|0; _Context_draw_rect($37,$39,$41,$46,$51,-16777216); $52 = $0; $53 = ((($52)) + 16|0); $54 = HEAP32[$53>>2]|0; $55 = $screen_x; $56 = (($55) + 3)|0; $57 = $screen_y; $58 = (($57) + 28)|0; $59 = $0; $60 = ((($59)) + 8|0); $61 = HEAP16[$60>>1]|0; $62 = $61&65535; $63 = (($62) - 6)|0; _Context_horizontal_line($54,$56,$58,$63,-16777216); $64 = $0; $65 = ((($64)) + 16|0); $66 = HEAP32[$65>>2]|0; $67 = $screen_x; $68 = (($67) + 3)|0; $69 = $screen_y; $70 = (($69) + 29)|0; $71 = $0; $72 = ((($71)) + 8|0); $73 = HEAP16[$72>>1]|0; $74 = $73&65535; $75 = (($74) - 6)|0; _Context_horizontal_line($66,$68,$70,$75,-16777216); $76 = $0; $77 = ((($76)) + 16|0); $78 = HEAP32[$77>>2]|0; $79 = $screen_x; $80 = (($79) + 3)|0; $81 = $screen_y; $82 = (($81) + 30)|0; $83 = $0; $84 = ((($83)) + 8|0); $85 = HEAP16[$84>>1]|0; $86 = $85&65535; $87 = (($86) - 6)|0; _Context_horizontal_line($78,$80,$82,$87,-16777216); $88 = $0; $89 = ((($88)) + 16|0); $90 = HEAP32[$89>>2]|0; $91 = $screen_x; $92 = (($91) + 3)|0; $93 = $screen_y; $94 = (($93) + 3)|0; $95 = $0; $96 = ((($95)) + 8|0); $97 = HEAP16[$96>>1]|0; $98 = $97&65535; $99 = (($98) - 6)|0; $100 = $0; $101 = HEAP32[$100>>2]|0; $102 = ((($101)) + 24|0); $103 = HEAP32[$102>>2]|0; $104 = $0; $105 = ($103|0)==($104|0); $106 = $105 ? -3108752 : -7307136; _Context_fill_rect($90,$92,$94,$99,25,$106); $107 = $0; $108 = ((($107)) + 16|0); $109 = HEAP32[$108>>2]|0; $110 = $0; $111 = ((($110)) + 48|0); $112 = HEAP32[$111>>2]|0; $113 = $screen_x; $114 = (($113) + 10)|0; $115 = $screen_y; $116 = (($115) + 10)|0; $117 = $0; $118 = HEAP32[$117>>2]|0; $119 = ((($118)) + 24|0); $120 = HEAP32[$119>>2]|0; $121 = $0; $122 = ($120|0)==($121|0); $123 = $122 ? -7968 : -4473925; _Context_draw_text($109,$112,$114,$116,$123); STACKTOP = sp;return; } function _Window_apply_bound_clipping($window,$in_recursion,$dirty_regions) { $window = $window|0; $in_recursion = $in_recursion|0; $dirty_regions = $dirty_regions|0; var $0 = 0, $1 = 0, $10 = 0, $100 = 0, $101 = 0, $102 = 0, $103 = 0, $104 = 0, $105 = 0, $106 = 0, $107 = 0, $108 = 0, $109 = 0, $11 = 0, $110 = 0, $111 = 0, $112 = 0, $113 = 0, $114 = 0, $115 = 0; var $116 = 0, $117 = 0, $118 = 0, $119 = 0, $12 = 0, $120 = 0, $121 = 0, $122 = 0, $123 = 0, $124 = 0, $125 = 0, $126 = 0, $127 = 0, $128 = 0, $129 = 0, $13 = 0, $130 = 0, $131 = 0, $132 = 0, $133 = 0; var $134 = 0, $135 = 0, $136 = 0, $137 = 0, $138 = 0, $139 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0; var $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0; var $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0, $9 = 0, $90 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $95 = 0, $96 = 0, $97 = 0, $98 = 0, $99 = 0; var $clip_windows = 0, $clipping_window = 0, $clone_dirty_rect = 0, $current_dirty_rect = 0, $i = 0, $or$cond = 0, $screen_x = 0, $screen_y = 0, $temp_rect = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 48|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $window; $1 = $in_recursion; $2 = $dirty_regions; $3 = $0; $4 = ((($3)) + 16|0); $5 = HEAP32[$4>>2]|0; $6 = ($5|0)!=(0|0); if (!($6)) { STACKTOP = sp;return; } $7 = $0; $8 = (_Window_screen_x($7)|0); $screen_x = $8; $9 = $0; $10 = (_Window_screen_y($9)|0); $screen_y = $10; $11 = $0; $12 = ((($11)) + 12|0); $13 = HEAP16[$12>>1]|0; $14 = $13&65535; $15 = $14 & 1; $16 = ($15|0)==(0); $17 = $1; $18 = ($17|0)!=(0); $or$cond = $16 & $18; if ($or$cond) { $19 = $screen_x; $20 = (($19) + 3)|0; $screen_x = $20; $21 = $screen_y; $22 = (($21) + 31)|0; $screen_y = $22; $23 = $screen_y; $24 = $screen_x; $25 = $screen_y; $26 = $0; $27 = ((($26)) + 10|0); $28 = HEAP16[$27>>1]|0; $29 = $28&65535; $30 = (($25) + ($29))|0; $31 = (($30) - 31)|0; $32 = (($31) - 3)|0; $33 = (($32) - 1)|0; $34 = $screen_x; $35 = $0; $36 = ((($35)) + 8|0); $37 = HEAP16[$36>>1]|0; $38 = $37&65535; $39 = (($34) + ($38))|0; $40 = (($39) - 6)|0; $41 = (($40) - 1)|0; $42 = (_Rect_new($23,$24,$33,$41)|0); $temp_rect = $42; } else { $43 = $screen_y; $44 = $screen_x; $45 = $screen_y; $46 = $0; $47 = ((($46)) + 10|0); $48 = HEAP16[$47>>1]|0; $49 = $48&65535; $50 = (($45) + ($49))|0; $51 = (($50) - 1)|0; $52 = $screen_x; $53 = $0; $54 = ((($53)) + 8|0); $55 = HEAP16[$54>>1]|0; $56 = $55&65535; $57 = (($52) + ($56))|0; $58 = (($57) - 1)|0; $59 = (_Rect_new($43,$44,$51,$58)|0); $temp_rect = $59; } $60 = $0; $61 = HEAP32[$60>>2]|0; $62 = ($61|0)!=(0|0); if ($62) { $98 = $0; $99 = HEAP32[$98>>2]|0; $100 = $2; _Window_apply_bound_clipping($99,1,$100); $101 = $0; $102 = ((($101)) + 16|0); $103 = HEAP32[$102>>2]|0; $104 = $temp_rect; _Context_intersect_clip_rect($103,$104); $105 = $0; $106 = HEAP32[$105>>2]|0; $107 = $0; $108 = (_Window_get_windows_above($106,$107)|0); $clip_windows = $108; while(1) { $109 = $clip_windows; $110 = HEAP32[$109>>2]|0; $111 = ($110|0)!=(0); $112 = $clip_windows; if (!($111)) { break; } $113 = (_List_remove_at($112,0)|0); $clipping_window = $113; $114 = $clipping_window; $115 = (_Window_screen_x($114)|0); $screen_x = $115; $116 = $clipping_window; $117 = (_Window_screen_y($116)|0); $screen_y = $117; $118 = $screen_y; $119 = $screen_x; $120 = $screen_y; $121 = $clipping_window; $122 = ((($121)) + 10|0); $123 = HEAP16[$122>>1]|0; $124 = $123&65535; $125 = (($120) + ($124))|0; $126 = (($125) - 1)|0; $127 = $screen_x; $128 = $clipping_window; $129 = ((($128)) + 8|0); $130 = HEAP16[$129>>1]|0; $131 = $130&65535; $132 = (($127) + ($131))|0; $133 = (($132) - 1)|0; $134 = (_Rect_new($118,$119,$126,$133)|0); $temp_rect = $134; $135 = $0; $136 = ((($135)) + 16|0); $137 = HEAP32[$136>>2]|0; $138 = $temp_rect; _Context_subtract_clip_rect($137,$138); $139 = $temp_rect; _free($139); } _free($112); STACKTOP = sp;return; } $63 = $2; $64 = ($63|0)!=(0|0); if (!($64)) { $94 = $0; $95 = ((($94)) + 16|0); $96 = HEAP32[$95>>2]|0; $97 = $temp_rect; _Context_add_clip_rect($96,$97); STACKTOP = sp;return; } $i = 0; while(1) { $65 = $i; $66 = $2; $67 = HEAP32[$66>>2]|0; $68 = ($65>>>0)<($67>>>0); if (!($68)) { break; } $69 = $2; $70 = $i; $71 = (_List_get_at($69,$70)|0); $current_dirty_rect = $71; $72 = $current_dirty_rect; $73 = HEAP32[$72>>2]|0; $74 = $current_dirty_rect; $75 = ((($74)) + 4|0); $76 = HEAP32[$75>>2]|0; $77 = $current_dirty_rect; $78 = ((($77)) + 8|0); $79 = HEAP32[$78>>2]|0; $80 = $current_dirty_rect; $81 = ((($80)) + 12|0); $82 = HEAP32[$81>>2]|0; $83 = (_Rect_new($73,$76,$79,$82)|0); $clone_dirty_rect = $83; $84 = $0; $85 = ((($84)) + 16|0); $86 = HEAP32[$85>>2]|0; $87 = $clone_dirty_rect; _Context_add_clip_rect($86,$87); $88 = $i; $89 = (($88) + 1)|0; $i = $89; } $90 = $0; $91 = ((($90)) + 16|0); $92 = HEAP32[$91>>2]|0; $93 = $temp_rect; _Context_intersect_clip_rect($92,$93); STACKTOP = sp;return; } function _Window_get_windows_above($parent,$child) { $parent = $parent|0; $child = $child|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0; var $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0; var $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0, $9 = 0, $90 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $95 = 0, $96 = 0, $97 = 0, $98 = 0, $99 = 0; var $current_window = 0, $i = 0, $return_list = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $parent; $2 = $child; $3 = (_List_new()|0); $return_list = $3; $4 = ($3|0)!=(0|0); if (!($4)) { $5 = $return_list; $0 = $5; $99 = $0; STACKTOP = sp;return ($99|0); } $i = 0; while(1) { $6 = $i; $7 = $1; $8 = ((($7)) + 28|0); $9 = HEAP32[$8>>2]|0; $10 = HEAP32[$9>>2]|0; $11 = ($6>>>0)<($10>>>0); if (!($11)) { break; } $12 = $2; $13 = $1; $14 = ((($13)) + 28|0); $15 = HEAP32[$14>>2]|0; $16 = $i; $17 = (_List_get_at($15,$16)|0); $18 = ($12|0)==($17|0); if ($18) { break; } $19 = $i; $20 = (($19) + 1)|0; $i = $20; } $21 = $i; $22 = (($21) + 1)|0; $i = $22; while(1) { $23 = $i; $24 = $1; $25 = ((($24)) + 28|0); $26 = HEAP32[$25>>2]|0; $27 = HEAP32[$26>>2]|0; $28 = ($23>>>0)<($27>>>0); if (!($28)) { break; } $29 = $1; $30 = ((($29)) + 28|0); $31 = HEAP32[$30>>2]|0; $32 = $i; $33 = (_List_get_at($31,$32)|0); $current_window = $33; $34 = $current_window; $35 = ((($34)) + 4|0); $36 = HEAP16[$35>>1]|0; $37 = $36 << 16 >> 16; $38 = $2; $39 = ((($38)) + 4|0); $40 = HEAP16[$39>>1]|0; $41 = $40 << 16 >> 16; $42 = $2; $43 = ((($42)) + 8|0); $44 = HEAP16[$43>>1]|0; $45 = $44&65535; $46 = (($41) + ($45))|0; $47 = (($46) - 1)|0; $48 = ($37|0)<=($47|0); if ($48) { $49 = $current_window; $50 = ((($49)) + 4|0); $51 = HEAP16[$50>>1]|0; $52 = $51 << 16 >> 16; $53 = $current_window; $54 = ((($53)) + 8|0); $55 = HEAP16[$54>>1]|0; $56 = $55&65535; $57 = (($52) + ($56))|0; $58 = (($57) - 1)|0; $59 = $2; $60 = ((($59)) + 4|0); $61 = HEAP16[$60>>1]|0; $62 = $61 << 16 >> 16; $63 = ($58|0)>=($62|0); if ($63) { $64 = $current_window; $65 = ((($64)) + 6|0); $66 = HEAP16[$65>>1]|0; $67 = $66 << 16 >> 16; $68 = $2; $69 = ((($68)) + 6|0); $70 = HEAP16[$69>>1]|0; $71 = $70 << 16 >> 16; $72 = $2; $73 = ((($72)) + 10|0); $74 = HEAP16[$73>>1]|0; $75 = $74&65535; $76 = (($71) + ($75))|0; $77 = (($76) - 1)|0; $78 = ($67|0)<=($77|0); if ($78) { $79 = $current_window; $80 = ((($79)) + 6|0); $81 = HEAP16[$80>>1]|0; $82 = $81 << 16 >> 16; $83 = $current_window; $84 = ((($83)) + 10|0); $85 = HEAP16[$84>>1]|0; $86 = $85&65535; $87 = (($82) + ($86))|0; $88 = (($87) - 1)|0; $89 = $2; $90 = ((($89)) + 6|0); $91 = HEAP16[$90>>1]|0; $92 = $91 << 16 >> 16; $93 = ($88|0)>=($92|0); if ($93) { $94 = $return_list; $95 = $current_window; (_List_add($94,$95)|0); } } } } $96 = $i; $97 = (($96) + 1)|0; $i = $97; } $98 = $return_list; $0 = $98; $99 = $0; STACKTOP = sp;return ($99|0); } function _Window_update_title($window) { $window = $window|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $window; $1 = $0; $2 = ((($1)) + 16|0); $3 = HEAP32[$2>>2]|0; $4 = ($3|0)!=(0|0); if (!($4)) { STACKTOP = sp;return; } $5 = $0; $6 = ((($5)) + 12|0); $7 = HEAP16[$6>>1]|0; $8 = $7&65535; $9 = $8 & 1; $10 = ($9|0)!=(0); if ($10) { STACKTOP = sp;return; } $11 = $0; _Window_apply_bound_clipping($11,0,0); $12 = $0; _Window_draw_border($12); $13 = $0; $14 = ((($13)) + 16|0); $15 = HEAP32[$14>>2]|0; _Context_clear_clip_rects($15); STACKTOP = sp;return; } function _Window_invalidate($window,$top,$left,$bottom,$right) { $window = $window|0; $top = $top|0; $left = $left|0; $bottom = $bottom|0; $right = $right|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0; var $dirty_rect = 0, $dirty_regions = 0, $origin_x = 0, $origin_y = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 48|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $window; $1 = $top; $2 = $left; $3 = $bottom; $4 = $right; $5 = $0; $6 = (_Window_screen_x($5)|0); $origin_x = $6; $7 = $0; $8 = (_Window_screen_y($7)|0); $origin_y = $8; $9 = $origin_y; $10 = $1; $11 = (($10) + ($9))|0; $1 = $11; $12 = $origin_y; $13 = $3; $14 = (($13) + ($12))|0; $3 = $14; $15 = $origin_x; $16 = $2; $17 = (($16) + ($15))|0; $2 = $17; $18 = $origin_x; $19 = $4; $20 = (($19) + ($18))|0; $4 = $20; $21 = (_List_new()|0); $dirty_regions = $21; $22 = ($21|0)!=(0|0); if (!($22)) { STACKTOP = sp;return; } $23 = $1; $24 = $2; $25 = $3; $26 = $4; $27 = (_Rect_new($23,$24,$25,$26)|0); $dirty_rect = $27; $28 = ($27|0)!=(0|0); $29 = $dirty_regions; if (!($28)) { _free($29); STACKTOP = sp;return; } $30 = $dirty_rect; $31 = (_List_add($29,$30)|0); $32 = ($31|0)!=(0); if ($32) { $35 = $0; $36 = $dirty_regions; _Window_paint($35,$36,0); $37 = $dirty_regions; (_List_remove_at($37,0)|0); $38 = $dirty_regions; _free($38); $39 = $dirty_rect; _free($39); STACKTOP = sp;return; } else { $33 = $dirty_regions; _free($33); $34 = $dirty_rect; _free($34); STACKTOP = sp;return; } } function _Window_paint($window,$dirty_regions,$paint_children) { $window = $window|0; $dirty_regions = $dirty_regions|0; $paint_children = $paint_children|0; var $0 = 0, $1 = 0, $10 = 0, $100 = 0, $101 = 0, $102 = 0, $103 = 0, $104 = 0, $105 = 0, $106 = 0, $107 = 0, $108 = 0, $109 = 0, $11 = 0, $110 = 0, $111 = 0, $112 = 0, $113 = 0, $114 = 0, $115 = 0; var $116 = 0, $117 = 0, $118 = 0, $119 = 0, $12 = 0, $120 = 0, $121 = 0, $122 = 0, $123 = 0, $124 = 0, $125 = 0, $126 = 0, $127 = 0, $128 = 0, $129 = 0, $13 = 0, $130 = 0, $131 = 0, $132 = 0, $133 = 0; var $134 = 0, $135 = 0, $136 = 0, $137 = 0, $138 = 0, $139 = 0, $14 = 0, $140 = 0, $141 = 0, $142 = 0, $143 = 0, $144 = 0, $145 = 0, $146 = 0, $147 = 0, $148 = 0, $149 = 0, $15 = 0, $150 = 0, $151 = 0; var $152 = 0, $153 = 0, $154 = 0, $155 = 0, $156 = 0, $157 = 0, $158 = 0, $159 = 0, $16 = 0, $160 = 0, $161 = 0, $162 = 0, $163 = 0, $164 = 0, $165 = 0, $166 = 0, $167 = 0, $168 = 0, $169 = 0, $17 = 0; var $170 = 0, $171 = 0, $172 = 0, $173 = 0, $174 = 0, $175 = 0, $176 = 0, $177 = 0, $178 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0, $27 = 0; var $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0, $45 = 0; var $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0, $63 = 0; var $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0, $81 = 0; var $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0, $9 = 0, $90 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $95 = 0, $96 = 0, $97 = 0, $98 = 0, $99 = 0, $child_screen_x = 0; var $child_screen_y = 0, $current_child = 0, $i = 0, $j = 0, $screen_x = 0, $screen_y = 0, $temp_rect = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 48|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $window; $1 = $dirty_regions; $2 = $paint_children; $3 = $0; $4 = ((($3)) + 16|0); $5 = HEAP32[$4>>2]|0; $6 = ($5|0)!=(0|0); if (!($6)) { STACKTOP = sp;return; } $7 = $0; $8 = $1; _Window_apply_bound_clipping($7,0,$8); $9 = $0; $10 = (_Window_screen_x($9)|0); $screen_x = $10; $11 = $0; $12 = (_Window_screen_y($11)|0); $screen_y = $12; $13 = $0; $14 = ((($13)) + 12|0); $15 = HEAP16[$14>>1]|0; $16 = $15&65535; $17 = $16 & 1; $18 = ($17|0)!=(0); if (!($18)) { $19 = $0; _Window_draw_border($19); $20 = $screen_x; $21 = (($20) + 3)|0; $screen_x = $21; $22 = $screen_y; $23 = (($22) + 31)|0; $screen_y = $23; $24 = $screen_y; $25 = $screen_x; $26 = $screen_y; $27 = $0; $28 = ((($27)) + 10|0); $29 = HEAP16[$28>>1]|0; $30 = $29&65535; $31 = (($26) + ($30))|0; $32 = (($31) - 31)|0; $33 = (($32) - 3)|0; $34 = (($33) - 1)|0; $35 = $screen_x; $36 = $0; $37 = ((($36)) + 8|0); $38 = HEAP16[$37>>1]|0; $39 = $38&65535; $40 = (($35) + ($39))|0; $41 = (($40) - 6)|0; $42 = (($41) - 1)|0; $43 = (_Rect_new($24,$25,$34,$42)|0); $temp_rect = $43; $44 = $0; $45 = ((($44)) + 16|0); $46 = HEAP32[$45>>2]|0; $47 = $temp_rect; _Context_intersect_clip_rect($46,$47); } $i = 0; while(1) { $48 = $i; $49 = $0; $50 = ((($49)) + 28|0); $51 = HEAP32[$50>>2]|0; $52 = HEAP32[$51>>2]|0; $53 = ($48>>>0)<($52>>>0); if (!($53)) { break; } $54 = $0; $55 = ((($54)) + 28|0); $56 = HEAP32[$55>>2]|0; $57 = $i; $58 = (_List_get_at($56,$57)|0); $current_child = $58; $59 = $current_child; $60 = (_Window_screen_x($59)|0); $child_screen_x = $60; $61 = $current_child; $62 = (_Window_screen_y($61)|0); $child_screen_y = $62; $63 = $child_screen_y; $64 = $child_screen_x; $65 = $child_screen_y; $66 = $current_child; $67 = ((($66)) + 10|0); $68 = HEAP16[$67>>1]|0; $69 = $68&65535; $70 = (($65) + ($69))|0; $71 = (($70) - 1)|0; $72 = $child_screen_x; $73 = $current_child; $74 = ((($73)) + 8|0); $75 = HEAP16[$74>>1]|0; $76 = $75&65535; $77 = (($72) + ($76))|0; $78 = (($77) - 1)|0; $79 = (_Rect_new($63,$64,$71,$78)|0); $temp_rect = $79; $80 = $0; $81 = ((($80)) + 16|0); $82 = HEAP32[$81>>2]|0; $83 = $temp_rect; _Context_subtract_clip_rect($82,$83); $84 = $temp_rect; _free($84); $85 = $i; $86 = (($85) + 1)|0; $i = $86; } $87 = $screen_x; $88 = $0; $89 = ((($88)) + 16|0); $90 = HEAP32[$89>>2]|0; $91 = ((($90)) + 8|0); HEAP32[$91>>2] = $87; $92 = $screen_y; $93 = $0; $94 = ((($93)) + 16|0); $95 = HEAP32[$94>>2]|0; $96 = ((($95)) + 12|0); HEAP32[$96>>2] = $92; $97 = $0; $98 = ((($97)) + 40|0); $99 = HEAP32[$98>>2]|0; $100 = $0; FUNCTION_TABLE_vi[$99 & 7]($100); $101 = $0; $102 = ((($101)) + 16|0); $103 = HEAP32[$102>>2]|0; _Context_clear_clip_rects($103); $104 = $0; $105 = ((($104)) + 16|0); $106 = HEAP32[$105>>2]|0; $107 = ((($106)) + 8|0); HEAP32[$107>>2] = 0; $108 = $0; $109 = ((($108)) + 16|0); $110 = HEAP32[$109>>2]|0; $111 = ((($110)) + 12|0); HEAP32[$111>>2] = 0; $112 = $2; $113 = ($112<<24>>24)!=(0); if (!($113)) { STACKTOP = sp;return; } $i = 0; while(1) { $114 = $i; $115 = $0; $116 = ((($115)) + 28|0); $117 = HEAP32[$116>>2]|0; $118 = HEAP32[$117>>2]|0; $119 = ($114>>>0)<($118>>>0); if (!($119)) { break; } $120 = $0; $121 = ((($120)) + 28|0); $122 = HEAP32[$121>>2]|0; $123 = $i; $124 = (_List_get_at($122,$123)|0); $current_child = $124; $125 = $1; $126 = ($125|0)!=(0|0); if ($126) { $j = 0; while(1) { $127 = $j; $128 = $1; $129 = HEAP32[$128>>2]|0; $130 = ($127>>>0)<($129>>>0); if (!($130)) { break; } $131 = $1; $132 = $j; $133 = (_List_get_at($131,$132)|0); $temp_rect = $133; $134 = $current_child; $135 = (_Window_screen_x($134)|0); $screen_x = $135; $136 = $current_child; $137 = (_Window_screen_y($136)|0); $screen_y = $137; $138 = $temp_rect; $139 = ((($138)) + 4|0); $140 = HEAP32[$139>>2]|0; $141 = $screen_x; $142 = $current_child; $143 = ((($142)) + 8|0); $144 = HEAP16[$143>>1]|0; $145 = $144&65535; $146 = (($141) + ($145))|0; $147 = (($146) - 1)|0; $148 = ($140|0)<=($147|0); if ($148) { $149 = $temp_rect; $150 = ((($149)) + 12|0); $151 = HEAP32[$150>>2]|0; $152 = $screen_x; $153 = ($151|0)>=($152|0); if ($153) { $154 = $temp_rect; $155 = HEAP32[$154>>2]|0; $156 = $screen_y; $157 = $current_child; $158 = ((($157)) + 10|0); $159 = HEAP16[$158>>1]|0; $160 = $159&65535; $161 = (($156) + ($160))|0; $162 = (($161) - 1)|0; $163 = ($155|0)<=($162|0); if ($163) { $164 = $temp_rect; $165 = ((($164)) + 8|0); $166 = HEAP32[$165>>2]|0; $167 = $screen_y; $168 = ($166|0)>=($167|0); if ($168) { break; } } } } $169 = $j; $170 = (($169) + 1)|0; $j = $170; } $171 = $j; $172 = $1; $173 = HEAP32[$172>>2]|0; $174 = ($171|0)==($173|0); if (!($174)) { label = 19; } } else { label = 19; } if ((label|0) == 19) { label = 0; $175 = $current_child; $176 = $1; _Window_paint($175,$176,1); } $177 = $i; $178 = (($177) + 1)|0; $i = $178; } STACKTOP = sp;return; } function _Window_get_windows_below($parent,$child) { $parent = $parent|0; $child = $child|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0; var $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0; var $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0, $9 = 0, $90 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $95 = 0, $96 = 0, $current_window = 0, $i = 0, $return_list = 0; var label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $parent; $2 = $child; $3 = (_List_new()|0); $return_list = $3; $4 = ($3|0)!=(0|0); if (!($4)) { $5 = $return_list; $0 = $5; $96 = $0; STACKTOP = sp;return ($96|0); } $6 = $1; $7 = ((($6)) + 28|0); $8 = HEAP32[$7>>2]|0; $9 = HEAP32[$8>>2]|0; $10 = (($9) - 1)|0; $i = $10; while(1) { $11 = $i; $12 = ($11|0)>(-1); if (!($12)) { break; } $13 = $2; $14 = $1; $15 = ((($14)) + 28|0); $16 = HEAP32[$15>>2]|0; $17 = $i; $18 = (_List_get_at($16,$17)|0); $19 = ($13|0)==($18|0); if ($19) { break; } $20 = $i; $21 = (($20) + -1)|0; $i = $21; } $22 = $i; $23 = (($22) + -1)|0; $i = $23; while(1) { $24 = $i; $25 = ($24|0)>(-1); if (!($25)) { break; } $26 = $1; $27 = ((($26)) + 28|0); $28 = HEAP32[$27>>2]|0; $29 = $i; $30 = (_List_get_at($28,$29)|0); $current_window = $30; $31 = $current_window; $32 = ((($31)) + 4|0); $33 = HEAP16[$32>>1]|0; $34 = $33 << 16 >> 16; $35 = $2; $36 = ((($35)) + 4|0); $37 = HEAP16[$36>>1]|0; $38 = $37 << 16 >> 16; $39 = $2; $40 = ((($39)) + 8|0); $41 = HEAP16[$40>>1]|0; $42 = $41&65535; $43 = (($38) + ($42))|0; $44 = (($43) - 1)|0; $45 = ($34|0)<=($44|0); if ($45) { $46 = $current_window; $47 = ((($46)) + 4|0); $48 = HEAP16[$47>>1]|0; $49 = $48 << 16 >> 16; $50 = $current_window; $51 = ((($50)) + 8|0); $52 = HEAP16[$51>>1]|0; $53 = $52&65535; $54 = (($49) + ($53))|0; $55 = (($54) - 1)|0; $56 = $2; $57 = ((($56)) + 4|0); $58 = HEAP16[$57>>1]|0; $59 = $58 << 16 >> 16; $60 = ($55|0)>=($59|0); if ($60) { $61 = $current_window; $62 = ((($61)) + 6|0); $63 = HEAP16[$62>>1]|0; $64 = $63 << 16 >> 16; $65 = $2; $66 = ((($65)) + 6|0); $67 = HEAP16[$66>>1]|0; $68 = $67 << 16 >> 16; $69 = $2; $70 = ((($69)) + 10|0); $71 = HEAP16[$70>>1]|0; $72 = $71&65535; $73 = (($68) + ($72))|0; $74 = (($73) - 1)|0; $75 = ($64|0)<=($74|0); if ($75) { $76 = $current_window; $77 = ((($76)) + 6|0); $78 = HEAP16[$77>>1]|0; $79 = $78 << 16 >> 16; $80 = $current_window; $81 = ((($80)) + 10|0); $82 = HEAP16[$81>>1]|0; $83 = $82&65535; $84 = (($79) + ($83))|0; $85 = (($84) - 1)|0; $86 = $2; $87 = ((($86)) + 6|0); $88 = HEAP16[$87>>1]|0; $89 = $88 << 16 >> 16; $90 = ($85|0)>=($89|0); if ($90) { $91 = $return_list; $92 = $current_window; (_List_add($91,$92)|0); } } } } $93 = $i; $94 = (($93) + -1)|0; $i = $94; } $95 = $return_list; $0 = $95; $96 = $0; STACKTOP = sp;return ($96|0); } function _Window_raise($window,$do_draw) { $window = $window|0; $do_draw = $do_draw|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $i = 0, $last_active = 0, $parent = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $window; $1 = $do_draw; $2 = $0; $3 = HEAP32[$2>>2]|0; $4 = ($3|0)!=(0|0); if (!($4)) { STACKTOP = sp;return; } $5 = $0; $6 = HEAP32[$5>>2]|0; $parent = $6; $7 = $parent; $8 = ((($7)) + 24|0); $9 = HEAP32[$8>>2]|0; $10 = $0; $11 = ($9|0)==($10|0); if ($11) { STACKTOP = sp;return; } $12 = $parent; $13 = ((($12)) + 24|0); $14 = HEAP32[$13>>2]|0; $last_active = $14; $i = 0; while(1) { $15 = $i; $16 = $parent; $17 = ((($16)) + 28|0); $18 = HEAP32[$17>>2]|0; $19 = HEAP32[$18>>2]|0; $20 = ($15>>>0)<($19>>>0); if (!($20)) { break; } $21 = $parent; $22 = ((($21)) + 28|0); $23 = HEAP32[$22>>2]|0; $24 = $i; $25 = (_List_get_at($23,$24)|0); $26 = $0; $27 = ($25|0)==($26|0); if ($27) { break; } $28 = $i; $29 = (($28) + 1)|0; $i = $29; } $30 = $parent; $31 = ((($30)) + 28|0); $32 = HEAP32[$31>>2]|0; $33 = $i; (_List_remove_at($32,$33)|0); $34 = $parent; $35 = ((($34)) + 28|0); $36 = HEAP32[$35>>2]|0; $37 = $0; (_List_add($36,$37)|0); $38 = $0; $39 = $parent; $40 = ((($39)) + 24|0); HEAP32[$40>>2] = $38; $41 = $1; $42 = ($41<<24>>24)!=(0); if (!($42)) { STACKTOP = sp;return; } $43 = $0; _Window_paint($43,0,1); $44 = $last_active; _Window_update_title($44); STACKTOP = sp;return; } function _Window_move($window,$new_x,$new_y) { $window = $window|0; $new_x = $new_x|0; $new_y = $new_y|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0; var $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0; var $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0, $9 = 0, $90 = 0, $91 = 0, $92 = 0, $93 = 0, $dirty_list = 0, $dirty_windows = 0, $new_window_rect = 0, $old_x = 0, $old_y = 0, $replacement_list = 0; var label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 64|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $new_window_rect = sp + 16|0; $0 = $window; $1 = $new_x; $2 = $new_y; $3 = $0; $4 = ((($3)) + 4|0); $5 = HEAP16[$4>>1]|0; $6 = $5 << 16 >> 16; $old_x = $6; $7 = $0; $8 = ((($7)) + 6|0); $9 = HEAP16[$8>>1]|0; $10 = $9 << 16 >> 16; $old_y = $10; $11 = $0; _Window_raise($11,0); $12 = $0; _Window_apply_bound_clipping($12,0,0); $13 = $1; $14 = $13&65535; $15 = $0; $16 = ((($15)) + 4|0); HEAP16[$16>>1] = $14; $17 = $2; $18 = $17&65535; $19 = $0; $20 = ((($19)) + 6|0); HEAP16[$20>>1] = $18; $21 = $0; $22 = (_Window_screen_y($21)|0); HEAP32[$new_window_rect>>2] = $22; $23 = $0; $24 = (_Window_screen_x($23)|0); $25 = ((($new_window_rect)) + 4|0); HEAP32[$25>>2] = $24; $26 = HEAP32[$new_window_rect>>2]|0; $27 = $0; $28 = ((($27)) + 10|0); $29 = HEAP16[$28>>1]|0; $30 = $29&65535; $31 = (($26) + ($30))|0; $32 = (($31) - 1)|0; $33 = ((($new_window_rect)) + 8|0); HEAP32[$33>>2] = $32; $34 = ((($new_window_rect)) + 4|0); $35 = HEAP32[$34>>2]|0; $36 = $0; $37 = ((($36)) + 8|0); $38 = HEAP16[$37>>1]|0; $39 = $38&65535; $40 = (($35) + ($39))|0; $41 = (($40) - 1)|0; $42 = ((($new_window_rect)) + 12|0); HEAP32[$42>>2] = $41; $43 = $old_x; $44 = $43&65535; $45 = $0; $46 = ((($45)) + 4|0); HEAP16[$46>>1] = $44; $47 = $old_y; $48 = $47&65535; $49 = $0; $50 = ((($49)) + 6|0); HEAP16[$50>>1] = $48; $51 = $0; $52 = ((($51)) + 16|0); $53 = HEAP32[$52>>2]|0; _Context_subtract_clip_rect($53,$new_window_rect); $54 = (_List_new()|0); $replacement_list = $54; $55 = ($54|0)!=(0|0); $56 = $0; $57 = ((($56)) + 16|0); $58 = HEAP32[$57>>2]|0; if (!($55)) { _Context_clear_clip_rects($58); STACKTOP = sp;return; } $59 = ((($58)) + 16|0); $60 = HEAP32[$59>>2]|0; $dirty_list = $60; $61 = $replacement_list; $62 = $0; $63 = ((($62)) + 16|0); $64 = HEAP32[$63>>2]|0; $65 = ((($64)) + 16|0); HEAP32[$65>>2] = $61; $66 = $0; $67 = HEAP32[$66>>2]|0; $68 = $0; $69 = (_Window_get_windows_below($67,$68)|0); $dirty_windows = $69; $70 = $1; $71 = $70&65535; $72 = $0; $73 = ((($72)) + 4|0); HEAP16[$73>>1] = $71; $74 = $2; $75 = $74&65535; $76 = $0; $77 = ((($76)) + 6|0); HEAP16[$77>>1] = $75; while(1) { $78 = $dirty_windows; $79 = HEAP32[$78>>2]|0; $80 = ($79|0)!=(0); if (!($80)) { break; } $81 = $dirty_windows; $82 = (_List_remove_at($81,0)|0); $83 = $dirty_list; _Window_paint($82,$83,1); } $84 = $0; $85 = HEAP32[$84>>2]|0; $86 = $dirty_list; _Window_paint($85,$86,0); while(1) { $87 = $dirty_list; $88 = HEAP32[$87>>2]|0; $89 = ($88|0)!=(0); $90 = $dirty_list; if (!($89)) { break; } $91 = (_List_remove_at($90,0)|0); _free($91); } _free($90); $92 = $dirty_windows; _free($92); $93 = $0; _Window_paint($93,0,1); STACKTOP = sp;return; } function _Window_process_mouse($window,$mouse_x,$mouse_y,$mouse_buttons) { $window = $window|0; $mouse_x = $mouse_x|0; $mouse_y = $mouse_y|0; $mouse_buttons = $mouse_buttons|0; var $0 = 0, $1 = 0, $10 = 0, $100 = 0, $101 = 0, $102 = 0, $103 = 0, $104 = 0, $105 = 0, $106 = 0, $107 = 0, $108 = 0, $109 = 0, $11 = 0, $110 = 0, $111 = 0, $112 = 0, $113 = 0, $114 = 0, $115 = 0; var $116 = 0, $117 = 0, $118 = 0, $119 = 0, $12 = 0, $120 = 0, $121 = 0, $122 = 0, $123 = 0, $124 = 0, $125 = 0, $126 = 0, $127 = 0, $128 = 0, $129 = 0, $13 = 0, $130 = 0, $131 = 0, $132 = 0, $133 = 0; var $134 = 0, $135 = 0, $136 = 0, $137 = 0, $138 = 0, $139 = 0, $14 = 0, $140 = 0, $141 = 0, $142 = 0, $143 = 0, $144 = 0, $145 = 0, $146 = 0, $147 = 0, $148 = 0, $149 = 0, $15 = 0, $150 = 0, $151 = 0; var $152 = 0, $153 = 0, $154 = 0, $155 = 0, $156 = 0, $157 = 0, $158 = 0, $159 = 0, $16 = 0, $160 = 0, $161 = 0, $162 = 0, $163 = 0, $164 = 0, $165 = 0, $166 = 0, $167 = 0, $168 = 0, $169 = 0, $17 = 0; var $170 = 0, $171 = 0, $172 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0, $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0; var $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0, $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0; var $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0, $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0; var $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0, $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0; var $88 = 0, $89 = 0, $9 = 0, $90 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $95 = 0, $96 = 0, $97 = 0, $98 = 0, $99 = 0, $child = 0, $i = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $window; $1 = $mouse_x; $2 = $mouse_y; $3 = $mouse_buttons; $4 = $0; $5 = ((($4)) + 28|0); $6 = HEAP32[$5>>2]|0; $7 = HEAP32[$6>>2]|0; $8 = (($7) - 1)|0; $i = $8; while(1) { $9 = $i; $10 = ($9|0)>=(0); if (!($10)) { break; } $11 = $0; $12 = ((($11)) + 28|0); $13 = HEAP32[$12>>2]|0; $14 = $i; $15 = (_List_get_at($13,$14)|0); $child = $15; $16 = $1; $17 = $16&65535; $18 = $child; $19 = ((($18)) + 4|0); $20 = HEAP16[$19>>1]|0; $21 = $20 << 16 >> 16; $22 = ($17|0)>=($21|0); if ($22) { $23 = $1; $24 = $23&65535; $25 = $child; $26 = ((($25)) + 4|0); $27 = HEAP16[$26>>1]|0; $28 = $27 << 16 >> 16; $29 = $child; $30 = ((($29)) + 8|0); $31 = HEAP16[$30>>1]|0; $32 = $31&65535; $33 = (($28) + ($32))|0; $34 = ($24|0)<($33|0); if ($34) { $35 = $2; $36 = $35&65535; $37 = $child; $38 = ((($37)) + 6|0); $39 = HEAP16[$38>>1]|0; $40 = $39 << 16 >> 16; $41 = ($36|0)>=($40|0); if ($41) { $42 = $2; $43 = $42&65535; $44 = $child; $45 = ((($44)) + 6|0); $46 = HEAP16[$45>>1]|0; $47 = $46 << 16 >> 16; $48 = $child; $49 = ((($48)) + 10|0); $50 = HEAP16[$49>>1]|0; $51 = $50&65535; $52 = (($47) + ($51))|0; $53 = ($43|0)<($52|0); if ($53) { label = 7; break; } } } } $124 = $i; $125 = (($124) + -1)|0; $i = $125; } do { if ((label|0) == 7) { $54 = $3; $55 = $54&255; $56 = ($55|0)!=(0); if ($56) { $57 = $0; $58 = ((($57)) + 36|0); $59 = HEAP8[$58>>0]|0; $60 = ($59<<24>>24)!=(0); if (!($60)) { $61 = $child; _Window_raise($61,1); $62 = $child; $63 = ((($62)) + 12|0); $64 = HEAP16[$63>>1]|0; $65 = $64&65535; $66 = $65 & 1; $67 = ($66|0)!=(0); if (!($67)) { $68 = $2; $69 = $68&65535; $70 = $child; $71 = ((($70)) + 6|0); $72 = HEAP16[$71>>1]|0; $73 = $72 << 16 >> 16; $74 = ($69|0)>=($73|0); if ($74) { $75 = $2; $76 = $75&65535; $77 = $child; $78 = ((($77)) + 6|0); $79 = HEAP16[$78>>1]|0; $80 = $79 << 16 >> 16; $81 = (($80) + 31)|0; $82 = ($76|0)<($81|0); if ($82) { $83 = $1; $84 = $83&65535; $85 = $child; $86 = ((($85)) + 4|0); $87 = HEAP16[$86>>1]|0; $88 = $87 << 16 >> 16; $89 = (($84) - ($88))|0; $90 = $89&65535; $91 = $0; $92 = ((($91)) + 32|0); HEAP16[$92>>1] = $90; $93 = $2; $94 = $93&65535; $95 = $child; $96 = ((($95)) + 6|0); $97 = HEAP16[$96>>1]|0; $98 = $97 << 16 >> 16; $99 = (($94) - ($98))|0; $100 = $99&65535; $101 = $0; $102 = ((($101)) + 34|0); HEAP16[$102>>1] = $100; $103 = $child; $104 = $0; $105 = ((($104)) + 20|0); HEAP32[$105>>2] = $103; break; } } } } } $106 = $child; $107 = $1; $108 = $107&65535; $109 = $child; $110 = ((($109)) + 4|0); $111 = HEAP16[$110>>1]|0; $112 = $111 << 16 >> 16; $113 = (($108) - ($112))|0; $114 = $113&65535; $115 = $2; $116 = $115&65535; $117 = $child; $118 = ((($117)) + 6|0); $119 = HEAP16[$118>>1]|0; $120 = $119 << 16 >> 16; $121 = (($116) - ($120))|0; $122 = $121&65535; $123 = $3; _Window_process_mouse($106,$114,$122,$123); } } while(0); $126 = $3; $127 = ($126<<24>>24)!=(0); if (!($127)) { $128 = $0; $129 = ((($128)) + 20|0); HEAP32[$129>>2] = 0; } $130 = $0; $131 = ((($130)) + 20|0); $132 = HEAP32[$131>>2]|0; $133 = ($132|0)!=(0|0); if ($133) { $134 = $0; $135 = ((($134)) + 20|0); $136 = HEAP32[$135>>2]|0; $137 = $1; $138 = $137&65535; $139 = $0; $140 = ((($139)) + 32|0); $141 = HEAP16[$140>>1]|0; $142 = $141&65535; $143 = (($138) - ($142))|0; $144 = $2; $145 = $144&65535; $146 = $0; $147 = ((($146)) + 34|0); $148 = HEAP16[$147>>1]|0; $149 = $148&65535; $150 = (($145) - ($149))|0; _Window_move($136,$143,$150); } $151 = $0; $152 = ((($151)) + 44|0); $153 = HEAP32[$152>>2]|0; $154 = ($153|0)!=(0|0); if (!($154)) { $170 = $3; $171 = $0; $172 = ((($171)) + 36|0); HEAP8[$172>>0] = $170; STACKTOP = sp;return; } $155 = $3; $156 = $155&255; $157 = ($156|0)!=(0); if (!($157)) { $170 = $3; $171 = $0; $172 = ((($171)) + 36|0); HEAP8[$172>>0] = $170; STACKTOP = sp;return; } $158 = $0; $159 = ((($158)) + 36|0); $160 = HEAP8[$159>>0]|0; $161 = ($160<<24>>24)!=(0); if ($161) { $170 = $3; $171 = $0; $172 = ((($171)) + 36|0); HEAP8[$172>>0] = $170; STACKTOP = sp;return; } $162 = $0; $163 = ((($162)) + 44|0); $164 = HEAP32[$163>>2]|0; $165 = $0; $166 = $1; $167 = $166&65535; $168 = $2; $169 = $168&65535; FUNCTION_TABLE_viii[$164 & 15]($165,$167,$169); $170 = $3; $171 = $0; $172 = ((($171)) + 36|0); HEAP8[$172>>0] = $170; STACKTOP = sp;return; } function _Window_update_context($window,$context) { $window = $window|0; $context = $context|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $i = 0; var label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $window; $1 = $context; $2 = $1; $3 = $0; $4 = ((($3)) + 16|0); HEAP32[$4>>2] = $2; $i = 0; while(1) { $5 = $i; $6 = $0; $7 = ((($6)) + 28|0); $8 = HEAP32[$7>>2]|0; $9 = HEAP32[$8>>2]|0; $10 = ($5>>>0)<($9>>>0); if (!($10)) { break; } $11 = $0; $12 = ((($11)) + 28|0); $13 = HEAP32[$12>>2]|0; $14 = $i; $15 = (_List_get_at($13,$14)|0); $16 = $1; _Window_update_context($15,$16); $17 = $i; $18 = (($17) + 1)|0; $i = $18; } STACKTOP = sp;return; } function _Window_insert_child($window,$child) { $window = $window|0; $child = $child|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $window; $1 = $child; $2 = $0; $3 = $1; HEAP32[$3>>2] = $2; $4 = $0; $5 = ((($4)) + 28|0); $6 = HEAP32[$5>>2]|0; $7 = $1; (_List_add($6,$7)|0); $8 = $1; $9 = $1; $10 = HEAP32[$9>>2]|0; $11 = ((($10)) + 24|0); HEAP32[$11>>2] = $8; $12 = $1; $13 = $0; $14 = ((($13)) + 16|0); $15 = HEAP32[$14>>2]|0; _Window_update_context($12,$15); STACKTOP = sp;return; } function _Window_set_title($window,$new_title) { $window = $window|0; $new_title = $new_title|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $7 = 0, $8 = 0; var $9 = 0, $i = 0, $len = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $window; $1 = $new_title; $2 = $0; $3 = ((($2)) + 48|0); $4 = HEAP32[$3>>2]|0; $5 = ($4|0)!=(0|0); if ($5) { $len = 0; while(1) { $6 = $len; $7 = $0; $8 = ((($7)) + 48|0); $9 = HEAP32[$8>>2]|0; $10 = (($9) + ($6)|0); $11 = HEAP8[$10>>0]|0; $12 = ($11<<24>>24)!=(0); if (!($12)) { break; } $13 = $len; $14 = (($13) + 1)|0; $len = $14; } $15 = $0; $16 = ((($15)) + 48|0); $17 = HEAP32[$16>>2]|0; _free($17); } $len = 0; while(1) { $18 = $len; $19 = $1; $20 = (($19) + ($18)|0); $21 = HEAP8[$20>>0]|0; $22 = ($21<<24>>24)!=(0); $23 = $len; $24 = (($23) + 1)|0; if (!($22)) { break; } $len = $24; } $25 = $24; $26 = (_malloc($25)|0); $27 = $0; $28 = ((($27)) + 48|0); HEAP32[$28>>2] = $26; $29 = ($26|0)!=(0|0); if (!($29)) { STACKTOP = sp;return; } $i = 0; while(1) { $30 = $i; $31 = $len; $32 = ($30|0)<=($31|0); if (!($32)) { break; } $33 = $i; $34 = $1; $35 = (($34) + ($33)|0); $36 = HEAP8[$35>>0]|0; $37 = $i; $38 = $0; $39 = ((($38)) + 48|0); $40 = HEAP32[$39>>2]|0; $41 = (($40) + ($37)|0); HEAP8[$41>>0] = $36; $42 = $i; $43 = (($42) + 1)|0; $i = $43; } $44 = $0; $45 = ((($44)) + 12|0); $46 = HEAP16[$45>>1]|0; $47 = $46&65535; $48 = $47 & 1; $49 = ($48|0)!=(0); $50 = $0; if ($49) { $51 = $0; $52 = ((($51)) + 10|0); $53 = HEAP16[$52>>1]|0; $54 = $53&65535; $55 = (($54) - 1)|0; $56 = $0; $57 = ((($56)) + 8|0); $58 = HEAP16[$57>>1]|0; $59 = $58&65535; $60 = (($59) - 1)|0; _Window_invalidate($50,0,0,$55,$60); STACKTOP = sp;return; } else { _Window_update_title($50); STACKTOP = sp;return; } } function _Window_append_title($window,$additional_chars) { $window = $window|0; $additional_chars = $additional_chars|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0; var $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0; var $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0; var $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0, $9 = 0, $90 = 0, $91 = 0, $92 = 0, $additional_length = 0, $i = 0, $new_string = 0, $original_length = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $window; $1 = $additional_chars; $2 = $0; $3 = ((($2)) + 48|0); $4 = HEAP32[$3>>2]|0; $5 = ($4|0)!=(0|0); if (!($5)) { $6 = $0; $7 = $1; _Window_set_title($6,$7); STACKTOP = sp;return; } $original_length = 0; while(1) { $8 = $original_length; $9 = $0; $10 = ((($9)) + 48|0); $11 = HEAP32[$10>>2]|0; $12 = (($11) + ($8)|0); $13 = HEAP8[$12>>0]|0; $14 = ($13<<24>>24)!=(0); if (!($14)) { break; } $15 = $original_length; $16 = (($15) + 1)|0; $original_length = $16; } $additional_length = 0; while(1) { $17 = $additional_length; $18 = $1; $19 = (($18) + ($17)|0); $20 = HEAP8[$19>>0]|0; $21 = ($20<<24>>24)!=(0); if (!($21)) { break; } $22 = $additional_length; $23 = (($22) + 1)|0; $additional_length = $23; } $24 = $original_length; $25 = $additional_length; $26 = (($24) + ($25))|0; $27 = (($26) + 1)|0; $28 = $27; $29 = (_malloc($28)|0); $new_string = $29; $30 = ($29|0)!=(0|0); if (!($30)) { STACKTOP = sp;return; } $i = 0; while(1) { $31 = $i; $32 = $0; $33 = ((($32)) + 48|0); $34 = HEAP32[$33>>2]|0; $35 = (($34) + ($31)|0); $36 = HEAP8[$35>>0]|0; $37 = ($36<<24>>24)!=(0); if (!($37)) { break; } $38 = $i; $39 = $0; $40 = ((($39)) + 48|0); $41 = HEAP32[$40>>2]|0; $42 = (($41) + ($38)|0); $43 = HEAP8[$42>>0]|0; $44 = $i; $45 = $new_string; $46 = (($45) + ($44)|0); HEAP8[$46>>0] = $43; $47 = $i; $48 = (($47) + 1)|0; $i = $48; } $i = 0; while(1) { $49 = $i; $50 = $1; $51 = (($50) + ($49)|0); $52 = HEAP8[$51>>0]|0; $53 = ($52<<24>>24)!=(0); if (!($53)) { break; } $54 = $i; $55 = $1; $56 = (($55) + ($54)|0); $57 = HEAP8[$56>>0]|0; $58 = $original_length; $59 = $i; $60 = (($58) + ($59))|0; $61 = $new_string; $62 = (($61) + ($60)|0); HEAP8[$62>>0] = $57; $63 = $i; $64 = (($63) + 1)|0; $i = $64; } $65 = $original_length; $66 = $i; $67 = (($65) + ($66))|0; $68 = $new_string; $69 = (($68) + ($67)|0); HEAP8[$69>>0] = 0; $70 = $0; $71 = ((($70)) + 48|0); $72 = HEAP32[$71>>2]|0; _free($72); $73 = $new_string; $74 = $0; $75 = ((($74)) + 48|0); HEAP32[$75>>2] = $73; $76 = $0; $77 = ((($76)) + 12|0); $78 = HEAP16[$77>>1]|0; $79 = $78&65535; $80 = $79 & 1; $81 = ($80|0)!=(0); $82 = $0; if ($81) { $83 = $0; $84 = ((($83)) + 10|0); $85 = HEAP16[$84>>1]|0; $86 = $85&65535; $87 = (($86) - 1)|0; $88 = $0; $89 = ((($88)) + 8|0); $90 = HEAP16[$89>>1]|0; $91 = $90&65535; $92 = (($91) - 1)|0; _Window_invalidate($82,0,0,$87,$92); STACKTOP = sp;return; } else { _Window_update_title($82); STACKTOP = sp;return; } } function _Desktop_new($context) { $context = $context|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0; var $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0; var $desktop = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $context; $2 = (_malloc(56)|0); $desktop = $2; $3 = ($2|0)!=(0|0); $4 = $desktop; if (!($3)) { $0 = $4; $39 = $0; STACKTOP = sp;return ($39|0); } $5 = $1; $6 = ((($5)) + 4|0); $7 = HEAP16[$6>>1]|0; $8 = $1; $9 = ((($8)) + 6|0); $10 = HEAP16[$9>>1]|0; $11 = $1; $12 = (_Window_init($4,0,0,$7,$10,1,$11)|0); $13 = ($12|0)!=(0); $14 = $desktop; if ($13) { $15 = ((($14)) + 40|0); HEAP32[$15>>2] = 7; $16 = $desktop; $17 = ((($16)) + 36|0); HEAP8[$17>>0] = 0; $18 = $desktop; $19 = ((($18)) + 16|0); $20 = HEAP32[$19>>2]|0; $21 = ((($20)) + 4|0); $22 = HEAP16[$21>>1]|0; $23 = $22&65535; $24 = (($23|0) / 2)&-1; $25 = $24&65535; $26 = $desktop; $27 = ((($26)) + 52|0); HEAP16[$27>>1] = $25; $28 = $desktop; $29 = ((($28)) + 16|0); $30 = HEAP32[$29>>2]|0; $31 = ((($30)) + 6|0); $32 = HEAP16[$31>>1]|0; $33 = $32&65535; $34 = (($33|0) / 2)&-1; $35 = $34&65535; $36 = $desktop; $37 = ((($36)) + 54|0); HEAP16[$37>>1] = $35; $38 = $desktop; $0 = $38; $39 = $0; STACKTOP = sp;return ($39|0); } else { _free($14); $0 = 0; $39 = $0; STACKTOP = sp;return ($39|0); } return (0)|0; } function _Desktop_paint_handler($desktop_window) { $desktop_window = $desktop_window|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $3 = 0, $4 = 0, $5 = 0; var $6 = 0, $7 = 0, $8 = 0, $9 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $desktop_window; $1 = $0; $2 = ((($1)) + 16|0); $3 = HEAP32[$2>>2]|0; $4 = $0; $5 = ((($4)) + 16|0); $6 = HEAP32[$5>>2]|0; $7 = ((($6)) + 4|0); $8 = HEAP16[$7>>1]|0; $9 = $8&65535; $10 = $0; $11 = ((($10)) + 16|0); $12 = HEAP32[$11>>2]|0; $13 = ((($12)) + 6|0); $14 = HEAP16[$13>>1]|0; $15 = $14&65535; _Context_fill_rect($3,0,0,$9,$15,-26317); $16 = $0; $17 = ((($16)) + 16|0); $18 = HEAP32[$17>>2]|0; $19 = $0; $20 = ((($19)) + 10|0); $21 = HEAP16[$20>>1]|0; $22 = $21&65535; $23 = (($22) - 12)|0; _Context_draw_text($18,4088,0,$23,-1); STACKTOP = sp;return; } function _Desktop_process_mouse($desktop,$mouse_x,$mouse_y,$mouse_buttons) { $desktop = $desktop|0; $mouse_x = $mouse_x|0; $mouse_y = $mouse_y|0; $mouse_buttons = $mouse_buttons|0; var $0 = 0, $1 = 0, $10 = 0, $100 = 0, $101 = 0, $102 = 0, $103 = 0, $104 = 0, $105 = 0, $106 = 0, $107 = 0, $108 = 0, $109 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0; var $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0, $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0, $33 = 0, $34 = 0, $35 = 0; var $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0, $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0, $51 = 0, $52 = 0, $53 = 0; var $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0, $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0, $7 = 0, $70 = 0, $71 = 0; var $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0, $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0, $88 = 0, $89 = 0, $9 = 0; var $90 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $95 = 0, $96 = 0, $97 = 0, $98 = 0, $99 = 0, $dirty_list = 0, $mouse_rect = 0, $x = 0, $y = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $desktop; $1 = $mouse_x; $2 = $mouse_y; $3 = $mouse_buttons; $4 = $0; $5 = $1; $6 = $2; $7 = $3; _Window_process_mouse($4,$5,$6,$7); $8 = (_List_new()|0); $dirty_list = $8; $9 = ($8|0)!=(0|0); if (!($9)) { STACKTOP = sp;return; } $10 = $0; $11 = ((($10)) + 54|0); $12 = HEAP16[$11>>1]|0; $13 = $12&65535; $14 = $0; $15 = ((($14)) + 52|0); $16 = HEAP16[$15>>1]|0; $17 = $16&65535; $18 = $0; $19 = ((($18)) + 54|0); $20 = HEAP16[$19>>1]|0; $21 = $20&65535; $22 = (($21) + 18)|0; $23 = (($22) - 1)|0; $24 = $0; $25 = ((($24)) + 52|0); $26 = HEAP16[$25>>1]|0; $27 = $26&65535; $28 = (($27) + 11)|0; $29 = (($28) - 1)|0; $30 = (_Rect_new($13,$17,$23,$29)|0); $mouse_rect = $30; $31 = ($30|0)!=(0|0); $32 = $dirty_list; if (!($31)) { _free($32); STACKTOP = sp;return; } $33 = $mouse_rect; (_List_add($32,$33)|0); $34 = $0; $35 = $dirty_list; _Window_paint($34,$35,1); $36 = $dirty_list; (_List_remove_at($36,0)|0); $37 = $dirty_list; _free($37); $38 = $mouse_rect; _free($38); $39 = $1; $40 = $0; $41 = ((($40)) + 52|0); HEAP16[$41>>1] = $39; $42 = $2; $43 = $0; $44 = ((($43)) + 54|0); HEAP16[$44>>1] = $42; $y = 0; while(1) { $45 = $y; $46 = ($45|0)<(18); if (!($46)) { label = 14; break; } $47 = $y; $48 = $2; $49 = $48&65535; $50 = (($47) + ($49))|0; $51 = $0; $52 = ((($51)) + 16|0); $53 = HEAP32[$52>>2]|0; $54 = ((($53)) + 6|0); $55 = HEAP16[$54>>1]|0; $56 = $55&65535; $57 = ($50|0)>=($56|0); if ($57) { label = 14; break; } $x = 0; while(1) { $58 = $x; $59 = ($58|0)<(11); if (!($59)) { break; } $60 = $x; $61 = $1; $62 = $61&65535; $63 = (($60) + ($62))|0; $64 = $0; $65 = ((($64)) + 16|0); $66 = HEAP32[$65>>2]|0; $67 = ((($66)) + 4|0); $68 = HEAP16[$67>>1]|0; $69 = $68&65535; $70 = ($63|0)>=($69|0); if ($70) { break; } $71 = $y; $72 = ($71*11)|0; $73 = $x; $74 = (($72) + ($73))|0; $75 = (12 + ($74<<2)|0); $76 = HEAP32[$75>>2]|0; $77 = $76 & -16777216; $78 = ($77|0)!=(0); if ($78) { $79 = $y; $80 = ($79*11)|0; $81 = $x; $82 = (($80) + ($81))|0; $83 = (12 + ($82<<2)|0); $84 = HEAP32[$83>>2]|0; $85 = $y; $86 = $2; $87 = $86&65535; $88 = (($85) + ($87))|0; $89 = $0; $90 = ((($89)) + 16|0); $91 = HEAP32[$90>>2]|0; $92 = ((($91)) + 4|0); $93 = HEAP16[$92>>1]|0; $94 = $93&65535; $95 = Math_imul($88, $94)|0; $96 = $x; $97 = $1; $98 = $97&65535; $99 = (($96) + ($98))|0; $100 = (($95) + ($99))|0; $101 = $0; $102 = ((($101)) + 16|0); $103 = HEAP32[$102>>2]|0; $104 = HEAP32[$103>>2]|0; $105 = (($104) + ($100<<2)|0); HEAP32[$105>>2] = $84; } $106 = $x; $107 = (($106) + 1)|0; $x = $107; } $108 = $y; $109 = (($108) + 1)|0; $y = $109; } if ((label|0) == 14) { STACKTOP = sp;return; } } function _main_mouse_callback($mouse_x,$mouse_y,$buttons) { $mouse_x = $mouse_x|0; $mouse_y = $mouse_y|0; $buttons = $buttons|0; var $0 = 0, $1 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $mouse_x; $1 = $mouse_y; $2 = $buttons; $3 = HEAP32[804>>2]|0; $4 = $0; $5 = $1; $6 = $2; _Desktop_process_mouse($3,$4,$5,$6); STACKTOP = sp;return; } function _spawn_calculator($button,$x,$y) { $button = $button|0; $x = $x|0; $y = $y|0; var $0 = 0, $1 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $temp_calc = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = $button; $1 = $x; $2 = $y; $3 = (_Calculator_new()|0); $temp_calc = $3; $4 = HEAP32[804>>2]|0; $5 = $temp_calc; _Window_insert_child($4,$5); $6 = $temp_calc; _Window_move($6,0,0); STACKTOP = sp;return; } function _main($argc,$argv) { $argc = $argc|0; $argv = $argv|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $context = 0; var $launch_button = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $0 = 0; $1 = $argc; $2 = $argv; $3 = (_Context_new(0,0,0)|0); $context = $3; $4 = $context; $5 = ((($4)) + 4|0); $6 = $context; $7 = ((($6)) + 6|0); $8 = (_fake_os_getActiveVesaBuffer($5,$7)|0); $9 = $context; HEAP32[$9>>2] = $8; $10 = $context; $11 = (_Desktop_new($10)|0); HEAP32[804>>2] = $11; $12 = (_Button_new(10,10,150,30)|0); $launch_button = $12; $13 = $launch_button; _Window_set_title($13,4117); $14 = $launch_button; $15 = ((($14)) + 56|0); HEAP32[$15>>2] = 8; $16 = HEAP32[804>>2]|0; $17 = $launch_button; _Window_insert_child($16,$17); $18 = HEAP32[804>>2]|0; _Window_paint($18,0,1); _fake_os_installMouseCallback(9); STACKTOP = sp;return 0; } function _Rect_new($top,$left,$bottom,$right) { $top = $top|0; $left = $left|0; $bottom = $bottom|0; $right = $right|0; var $0 = 0, $1 = 0, $10 = 0, $11 = 0, $12 = 0, $13 = 0, $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0; var $9 = 0, $rect = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $top; $2 = $left; $3 = $bottom; $4 = $right; $5 = (_malloc(16)|0); $rect = $5; $6 = ($5|0)!=(0|0); if ($6) { $8 = $1; $9 = $rect; HEAP32[$9>>2] = $8; $10 = $2; $11 = $rect; $12 = ((($11)) + 4|0); HEAP32[$12>>2] = $10; $13 = $3; $14 = $rect; $15 = ((($14)) + 8|0); HEAP32[$15>>2] = $13; $16 = $4; $17 = $rect; $18 = ((($17)) + 12|0); HEAP32[$18>>2] = $16; $19 = $rect; $0 = $19; $20 = $0; STACKTOP = sp;return ($20|0); } else { $7 = $rect; $0 = $7; $20 = $0; STACKTOP = sp;return ($20|0); } return (0)|0; } function _Rect_split($subject_rect,$cutting_rect) { $subject_rect = $subject_rect|0; $cutting_rect = $cutting_rect|0; var $0 = 0, $1 = 0, $10 = 0, $100 = 0, $101 = 0, $102 = 0, $103 = 0, $104 = 0, $105 = 0, $106 = 0, $107 = 0, $108 = 0, $109 = 0, $11 = 0, $110 = 0, $111 = 0, $112 = 0, $113 = 0, $114 = 0, $115 = 0; var $116 = 0, $117 = 0, $118 = 0, $119 = 0, $12 = 0, $120 = 0, $121 = 0, $122 = 0, $123 = 0, $124 = 0, $125 = 0, $126 = 0, $127 = 0, $128 = 0, $129 = 0, $13 = 0, $130 = 0, $131 = 0, $132 = 0, $133 = 0; var $134 = 0, $135 = 0, $136 = 0, $137 = 0, $138 = 0, $139 = 0, $14 = 0, $140 = 0, $141 = 0, $142 = 0, $143 = 0, $144 = 0, $145 = 0, $146 = 0, $147 = 0, $148 = 0, $149 = 0, $15 = 0, $150 = 0, $151 = 0; var $152 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0, $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0, $32 = 0; var $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0, $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0, $50 = 0; var $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0, $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0, $69 = 0; var $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0, $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0, $87 = 0; var $88 = 0, $89 = 0, $9 = 0, $90 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $95 = 0, $96 = 0, $97 = 0, $98 = 0, $99 = 0, $output_rects = 0, $subject_copy = 0, $temp_rect = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 48|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $subject_copy = sp + 8|0; $1 = $subject_rect; $2 = $cutting_rect; $3 = (_List_new()|0); $output_rects = $3; $4 = ($3|0)!=(0|0); if (!($4)) { $5 = $output_rects; $0 = $5; $152 = $0; STACKTOP = sp;return ($152|0); } $6 = $1; $7 = HEAP32[$6>>2]|0; HEAP32[$subject_copy>>2] = $7; $8 = $1; $9 = ((($8)) + 4|0); $10 = HEAP32[$9>>2]|0; $11 = ((($subject_copy)) + 4|0); HEAP32[$11>>2] = $10; $12 = $1; $13 = ((($12)) + 8|0); $14 = HEAP32[$13>>2]|0; $15 = ((($subject_copy)) + 8|0); HEAP32[$15>>2] = $14; $16 = $1; $17 = ((($16)) + 12|0); $18 = HEAP32[$17>>2]|0; $19 = ((($subject_copy)) + 12|0); HEAP32[$19>>2] = $18; $20 = $2; $21 = ((($20)) + 4|0); $22 = HEAP32[$21>>2]|0; $23 = ((($subject_copy)) + 4|0); $24 = HEAP32[$23>>2]|0; $25 = ($22|0)>($24|0); do { if ($25) { $26 = $2; $27 = ((($26)) + 4|0); $28 = HEAP32[$27>>2]|0; $29 = ((($subject_copy)) + 12|0); $30 = HEAP32[$29>>2]|0; $31 = ($28|0)<=($30|0); if ($31) { $32 = HEAP32[$subject_copy>>2]|0; $33 = ((($subject_copy)) + 4|0); $34 = HEAP32[$33>>2]|0; $35 = ((($subject_copy)) + 8|0); $36 = HEAP32[$35>>2]|0; $37 = $2; $38 = ((($37)) + 4|0); $39 = HEAP32[$38>>2]|0; $40 = (($39) - 1)|0; $41 = (_Rect_new($32,$34,$36,$40)|0); $temp_rect = $41; $42 = ($41|0)!=(0|0); $43 = $output_rects; if ($42) { $44 = $temp_rect; (_List_add($43,$44)|0); $45 = $2; $46 = ((($45)) + 4|0); $47 = HEAP32[$46>>2]|0; $48 = ((($subject_copy)) + 4|0); HEAP32[$48>>2] = $47; break; } _free($43); $0 = 0; $152 = $0; STACKTOP = sp;return ($152|0); } } } while(0); $49 = $2; $50 = HEAP32[$49>>2]|0; $51 = HEAP32[$subject_copy>>2]|0; $52 = ($50|0)>($51|0); do { if ($52) { $53 = $2; $54 = HEAP32[$53>>2]|0; $55 = ((($subject_copy)) + 8|0); $56 = HEAP32[$55>>2]|0; $57 = ($54|0)<=($56|0); if ($57) { $58 = HEAP32[$subject_copy>>2]|0; $59 = ((($subject_copy)) + 4|0); $60 = HEAP32[$59>>2]|0; $61 = $2; $62 = HEAP32[$61>>2]|0; $63 = (($62) - 1)|0; $64 = ((($subject_copy)) + 12|0); $65 = HEAP32[$64>>2]|0; $66 = (_Rect_new($58,$60,$63,$65)|0); $temp_rect = $66; $67 = ($66|0)!=(0|0); if ($67) { $75 = $output_rects; $76 = $temp_rect; (_List_add($75,$76)|0); $77 = $2; $78 = HEAP32[$77>>2]|0; HEAP32[$subject_copy>>2] = $78; break; } while(1) { $68 = $output_rects; $69 = HEAP32[$68>>2]|0; $70 = ($69|0)!=(0); if (!($70)) { break; } $71 = $temp_rect; _free($71); $72 = $output_rects; $73 = (_List_remove_at($72,0)|0); $temp_rect = $73; } $74 = $output_rects; _free($74); $0 = 0; $152 = $0; STACKTOP = sp;return ($152|0); } } } while(0); $79 = $2; $80 = ((($79)) + 12|0); $81 = HEAP32[$80>>2]|0; $82 = ((($subject_copy)) + 4|0); $83 = HEAP32[$82>>2]|0; $84 = ($81|0)>=($83|0); do { if ($84) { $85 = $2; $86 = ((($85)) + 12|0); $87 = HEAP32[$86>>2]|0; $88 = ((($subject_copy)) + 12|0); $89 = HEAP32[$88>>2]|0; $90 = ($87|0)<($89|0); if ($90) { $91 = HEAP32[$subject_copy>>2]|0; $92 = $2; $93 = ((($92)) + 12|0); $94 = HEAP32[$93>>2]|0; $95 = (($94) + 1)|0; $96 = ((($subject_copy)) + 8|0); $97 = HEAP32[$96>>2]|0; $98 = ((($subject_copy)) + 12|0); $99 = HEAP32[$98>>2]|0; $100 = (_Rect_new($91,$95,$97,$99)|0); $temp_rect = $100; $101 = ($100|0)!=(0|0); if ($101) { $109 = $output_rects; $110 = $temp_rect; (_List_add($109,$110)|0); $111 = $2; $112 = ((($111)) + 12|0); $113 = HEAP32[$112>>2]|0; $114 = ((($subject_copy)) + 12|0); HEAP32[$114>>2] = $113; break; } while(1) { $102 = $output_rects; $103 = HEAP32[$102>>2]|0; $104 = ($103|0)!=(0); if (!($104)) { break; } $105 = $temp_rect; _free($105); $106 = $output_rects; $107 = (_List_remove_at($106,0)|0); $temp_rect = $107; } $108 = $output_rects; _free($108); $0 = 0; $152 = $0; STACKTOP = sp;return ($152|0); } } } while(0); $115 = $2; $116 = ((($115)) + 8|0); $117 = HEAP32[$116>>2]|0; $118 = HEAP32[$subject_copy>>2]|0; $119 = ($117|0)>=($118|0); do { if ($119) { $120 = $2; $121 = ((($120)) + 8|0); $122 = HEAP32[$121>>2]|0; $123 = ((($subject_copy)) + 8|0); $124 = HEAP32[$123>>2]|0; $125 = ($122|0)<($124|0); if ($125) { $126 = $2; $127 = ((($126)) + 8|0); $128 = HEAP32[$127>>2]|0; $129 = (($128) + 1)|0; $130 = ((($subject_copy)) + 4|0); $131 = HEAP32[$130>>2]|0; $132 = ((($subject_copy)) + 8|0); $133 = HEAP32[$132>>2]|0; $134 = ((($subject_copy)) + 12|0); $135 = HEAP32[$134>>2]|0; $136 = (_Rect_new($129,$131,$133,$135)|0); $temp_rect = $136; $137 = ($136|0)!=(0|0); if ($137) { $145 = $output_rects; $146 = $temp_rect; (_List_add($145,$146)|0); $147 = $2; $148 = ((($147)) + 8|0); $149 = HEAP32[$148>>2]|0; $150 = ((($subject_copy)) + 8|0); HEAP32[$150>>2] = $149; break; } while(1) { $138 = $output_rects; $139 = HEAP32[$138>>2]|0; $140 = ($139|0)!=(0); if (!($140)) { break; } $141 = $temp_rect; _free($141); $142 = $output_rects; $143 = (_List_remove_at($142,0)|0); $temp_rect = $143; } $144 = $output_rects; _free($144); $0 = 0; $152 = $0; STACKTOP = sp;return ($152|0); } } } while(0); $151 = $output_rects; $0 = $151; $152 = $0; STACKTOP = sp;return ($152|0); } function _Rect_intersect($rect_a,$rect_b) { $rect_a = $rect_a|0; $rect_b = $rect_b|0; var $0 = 0, $1 = 0, $10 = 0, $100 = 0, $101 = 0, $102 = 0, $103 = 0, $104 = 0, $105 = 0, $106 = 0, $107 = 0, $108 = 0, $109 = 0, $11 = 0, $110 = 0, $111 = 0, $112 = 0, $113 = 0, $12 = 0, $13 = 0; var $14 = 0, $15 = 0, $16 = 0, $17 = 0, $18 = 0, $19 = 0, $2 = 0, $20 = 0, $21 = 0, $22 = 0, $23 = 0, $24 = 0, $25 = 0, $26 = 0, $27 = 0, $28 = 0, $29 = 0, $3 = 0, $30 = 0, $31 = 0; var $32 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0, $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0; var $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0, $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0; var $69 = 0, $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0, $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0; var $87 = 0, $88 = 0, $89 = 0, $9 = 0, $90 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $95 = 0, $96 = 0, $97 = 0, $98 = 0, $99 = 0, $result_rect = 0, label = 0, sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $1 = $rect_a; $2 = $rect_b; $3 = $1; $4 = ((($3)) + 4|0); $5 = HEAP32[$4>>2]|0; $6 = $2; $7 = ((($6)) + 12|0); $8 = HEAP32[$7>>2]|0; $9 = ($5|0)<=($8|0); if ($9) { $10 = $1; $11 = ((($10)) + 12|0); $12 = HEAP32[$11>>2]|0; $13 = $2; $14 = ((($13)) + 4|0); $15 = HEAP32[$14>>2]|0; $16 = ($12|0)>=($15|0); if ($16) { $17 = $1; $18 = HEAP32[$17>>2]|0; $19 = $2; $20 = ((($19)) + 8|0); $21 = HEAP32[$20>>2]|0; $22 = ($18|0)<=($21|0); if ($22) { $23 = $1; $24 = ((($23)) + 8|0); $25 = HEAP32[$24>>2]|0; $26 = $2; $27 = HEAP32[$26>>2]|0; $28 = ($25|0)>=($27|0); if ($28) { $29 = $1; $30 = HEAP32[$29>>2]|0; $31 = $1; $32 = ((($31)) + 4|0); $33 = HEAP32[$32>>2]|0; $34 = $1; $35 = ((($34)) + 8|0); $36 = HEAP32[$35>>2]|0; $37 = $1; $38 = ((($37)) + 12|0); $39 = HEAP32[$38>>2]|0; $40 = (_Rect_new($30,$33,$36,$39)|0); $result_rect = $40; $41 = ($40|0)!=(0|0); if (!($41)) { $0 = 0; $113 = $0; STACKTOP = sp;return ($113|0); } $42 = $2; $43 = ((($42)) + 4|0); $44 = HEAP32[$43>>2]|0; $45 = $result_rect; $46 = ((($45)) + 4|0); $47 = HEAP32[$46>>2]|0; $48 = ($44|0)>($47|0); if ($48) { $49 = $2; $50 = ((($49)) + 4|0); $51 = HEAP32[$50>>2]|0; $52 = $result_rect; $53 = ((($52)) + 12|0); $54 = HEAP32[$53>>2]|0; $55 = ($51|0)<=($54|0); if ($55) { $56 = $2; $57 = ((($56)) + 4|0); $58 = HEAP32[$57>>2]|0; $59 = $result_rect; $60 = ((($59)) + 4|0); HEAP32[$60>>2] = $58; } } $61 = $2; $62 = HEAP32[$61>>2]|0; $63 = $result_rect; $64 = HEAP32[$63>>2]|0; $65 = ($62|0)>($64|0); if ($65) { $66 = $2; $67 = HEAP32[$66>>2]|0; $68 = $result_rect; $69 = ((($68)) + 8|0); $70 = HEAP32[$69>>2]|0; $71 = ($67|0)<=($70|0); if ($71) { $72 = $2; $73 = HEAP32[$72>>2]|0; $74 = $result_rect; HEAP32[$74>>2] = $73; } } $75 = $2; $76 = ((($75)) + 12|0); $77 = HEAP32[$76>>2]|0; $78 = $result_rect; $79 = ((($78)) + 4|0); $80 = HEAP32[$79>>2]|0; $81 = ($77|0)>=($80|0); if ($81) { $82 = $2; $83 = ((($82)) + 12|0); $84 = HEAP32[$83>>2]|0; $85 = $result_rect; $86 = ((($85)) + 12|0); $87 = HEAP32[$86>>2]|0; $88 = ($84|0)<($87|0); if ($88) { $89 = $2; $90 = ((($89)) + 12|0); $91 = HEAP32[$90>>2]|0; $92 = $result_rect; $93 = ((($92)) + 12|0); HEAP32[$93>>2] = $91; } } $94 = $2; $95 = ((($94)) + 8|0); $96 = HEAP32[$95>>2]|0; $97 = $result_rect; $98 = HEAP32[$97>>2]|0; $99 = ($96|0)>=($98|0); if ($99) { $100 = $2; $101 = ((($100)) + 8|0); $102 = HEAP32[$101>>2]|0; $103 = $result_rect; $104 = ((($103)) + 8|0); $105 = HEAP32[$104>>2]|0; $106 = ($102|0)<($105|0); if ($106) { $107 = $2; $108 = ((($107)) + 8|0); $109 = HEAP32[$108>>2]|0; $110 = $result_rect; $111 = ((($110)) + 8|0); HEAP32[$111>>2] = $109; } } $112 = $result_rect; $0 = $112; $113 = $0; STACKTOP = sp;return ($113|0); } } } } $0 = 0; $113 = $0; STACKTOP = sp;return ($113|0); } function ___errno_location() { var $$0 = 0, $0 = 0, $1 = 0, $2 = 0, $3 = 0, label = 0, sp = 0; sp = STACKTOP; $0 = (0|0)==(0|0); if ($0) { $$0 = 808; } else { $1 = (_pthread_self()|0); $2 = ((($1)) + 60|0); $3 = HEAP32[$2>>2]|0; $$0 = $3; } return ($$0|0); } function _malloc($bytes) { $bytes = $bytes|0; var $$3$i = 0, $$lcssa = 0, $$lcssa211 = 0, $$lcssa215 = 0, $$lcssa216 = 0, $$lcssa217 = 0, $$lcssa219 = 0, $$lcssa222 = 0, $$lcssa224 = 0, $$lcssa226 = 0, $$lcssa228 = 0, $$lcssa230 = 0, $$lcssa232 = 0, $$pre = 0, $$pre$i = 0, $$pre$i$i = 0, $$pre$i22$i = 0, $$pre$i25 = 0, $$pre$phi$i$iZ2D = 0, $$pre$phi$i23$iZ2D = 0; var $$pre$phi$i26Z2D = 0, $$pre$phi$iZ2D = 0, $$pre$phi58$i$iZ2D = 0, $$pre$phiZ2D = 0, $$pre105 = 0, $$pre106 = 0, $$pre14$i$i = 0, $$pre43$i = 0, $$pre56$i$i = 0, $$pre57$i$i = 0, $$pre8$i = 0, $$rsize$0$i = 0, $$rsize$3$i = 0, $$sum = 0, $$sum$i$i = 0, $$sum$i$i$i = 0, $$sum$i13$i = 0, $$sum$i14$i = 0, $$sum$i17$i = 0, $$sum$i19$i = 0; var $$sum$i2334 = 0, $$sum$i32 = 0, $$sum$i35 = 0, $$sum1 = 0, $$sum1$i = 0, $$sum1$i$i = 0, $$sum1$i15$i = 0, $$sum1$i20$i = 0, $$sum1$i24 = 0, $$sum10 = 0, $$sum10$i = 0, $$sum10$i$i = 0, $$sum11$i = 0, $$sum11$i$i = 0, $$sum1112 = 0, $$sum112$i = 0, $$sum113$i = 0, $$sum114$i = 0, $$sum115$i = 0, $$sum116$i = 0; var $$sum117$i = 0, $$sum118$i = 0, $$sum119$i = 0, $$sum12$i = 0, $$sum12$i$i = 0, $$sum120$i = 0, $$sum121$i = 0, $$sum122$i = 0, $$sum123$i = 0, $$sum124$i = 0, $$sum125$i = 0, $$sum13$i = 0, $$sum13$i$i = 0, $$sum14$i$i = 0, $$sum15$i = 0, $$sum15$i$i = 0, $$sum16$i = 0, $$sum16$i$i = 0, $$sum17$i = 0, $$sum17$i$i = 0; var $$sum18$i = 0, $$sum1819$i$i = 0, $$sum2 = 0, $$sum2$i = 0, $$sum2$i$i = 0, $$sum2$i$i$i = 0, $$sum2$i16$i = 0, $$sum2$i18$i = 0, $$sum2$i21$i = 0, $$sum20$i$i = 0, $$sum21$i$i = 0, $$sum22$i$i = 0, $$sum23$i$i = 0, $$sum24$i$i = 0, $$sum25$i$i = 0, $$sum27$i$i = 0, $$sum28$i$i = 0, $$sum29$i$i = 0, $$sum3$i = 0, $$sum3$i27 = 0; var $$sum30$i$i = 0, $$sum3132$i$i = 0, $$sum34$i$i = 0, $$sum3536$i$i = 0, $$sum3738$i$i = 0, $$sum39$i$i = 0, $$sum4 = 0, $$sum4$i = 0, $$sum4$i$i = 0, $$sum4$i28 = 0, $$sum40$i$i = 0, $$sum41$i$i = 0, $$sum42$i$i = 0, $$sum5$i = 0, $$sum5$i$i = 0, $$sum56 = 0, $$sum6$i = 0, $$sum67$i$i = 0, $$sum7$i = 0, $$sum8$i = 0; var $$sum9 = 0, $$sum9$i = 0, $$sum9$i$i = 0, $$tsize$1$i = 0, $$v$0$i = 0, $0 = 0, $1 = 0, $10 = 0, $100 = 0, $1000 = 0, $1001 = 0, $1002 = 0, $1003 = 0, $1004 = 0, $1005 = 0, $1006 = 0, $1007 = 0, $1008 = 0, $1009 = 0, $101 = 0; var $1010 = 0, $1011 = 0, $1012 = 0, $1013 = 0, $1014 = 0, $1015 = 0, $1016 = 0, $1017 = 0, $1018 = 0, $1019 = 0, $102 = 0, $1020 = 0, $1021 = 0, $1022 = 0, $1023 = 0, $1024 = 0, $1025 = 0, $1026 = 0, $1027 = 0, $1028 = 0; var $1029 = 0, $103 = 0, $1030 = 0, $1031 = 0, $1032 = 0, $1033 = 0, $1034 = 0, $1035 = 0, $1036 = 0, $1037 = 0, $1038 = 0, $1039 = 0, $104 = 0, $1040 = 0, $1041 = 0, $1042 = 0, $1043 = 0, $1044 = 0, $1045 = 0, $1046 = 0; var $1047 = 0, $1048 = 0, $1049 = 0, $105 = 0, $1050 = 0, $1051 = 0, $1052 = 0, $1053 = 0, $1054 = 0, $1055 = 0, $1056 = 0, $1057 = 0, $1058 = 0, $1059 = 0, $106 = 0, $1060 = 0, $1061 = 0, $1062 = 0, $1063 = 0, $1064 = 0; var $1065 = 0, $1066 = 0, $1067 = 0, $1068 = 0, $1069 = 0, $107 = 0, $1070 = 0, $108 = 0, $109 = 0, $11 = 0, $110 = 0, $111 = 0, $112 = 0, $113 = 0, $114 = 0, $115 = 0, $116 = 0, $117 = 0, $118 = 0, $119 = 0; var $12 = 0, $120 = 0, $121 = 0, $122 = 0, $123 = 0, $124 = 0, $125 = 0, $126 = 0, $127 = 0, $128 = 0, $129 = 0, $13 = 0, $130 = 0, $131 = 0, $132 = 0, $133 = 0, $134 = 0, $135 = 0, $136 = 0, $137 = 0; var $138 = 0, $139 = 0, $14 = 0, $140 = 0, $141 = 0, $142 = 0, $143 = 0, $144 = 0, $145 = 0, $146 = 0, $147 = 0, $148 = 0, $149 = 0, $15 = 0, $150 = 0, $151 = 0, $152 = 0, $153 = 0, $154 = 0, $155 = 0; var $156 = 0, $157 = 0, $158 = 0, $159 = 0, $16 = 0, $160 = 0, $161 = 0, $162 = 0, $163 = 0, $164 = 0, $165 = 0, $166 = 0, $167 = 0, $168 = 0, $169 = 0, $17 = 0, $170 = 0, $171 = 0, $172 = 0, $173 = 0; var $174 = 0, $175 = 0, $176 = 0, $177 = 0, $178 = 0, $179 = 0, $18 = 0, $180 = 0, $181 = 0, $182 = 0, $183 = 0, $184 = 0, $185 = 0, $186 = 0, $187 = 0, $188 = 0, $189 = 0, $19 = 0, $190 = 0, $191 = 0; var $192 = 0, $193 = 0, $194 = 0, $195 = 0, $196 = 0, $197 = 0, $198 = 0, $199 = 0, $2 = 0, $20 = 0, $200 = 0, $201 = 0, $202 = 0, $203 = 0, $204 = 0, $205 = 0, $206 = 0, $207 = 0, $208 = 0, $209 = 0; var $21 = 0, $210 = 0, $211 = 0, $212 = 0, $213 = 0, $214 = 0, $215 = 0, $216 = 0, $217 = 0, $218 = 0, $219 = 0, $22 = 0, $220 = 0, $221 = 0, $222 = 0, $223 = 0, $224 = 0, $225 = 0, $226 = 0, $227 = 0; var $228 = 0, $229 = 0, $23 = 0, $230 = 0, $231 = 0, $232 = 0, $233 = 0, $234 = 0, $235 = 0, $236 = 0, $237 = 0, $238 = 0, $239 = 0, $24 = 0, $240 = 0, $241 = 0, $242 = 0, $243 = 0, $244 = 0, $245 = 0; var $246 = 0, $247 = 0, $248 = 0, $249 = 0, $25 = 0, $250 = 0, $251 = 0, $252 = 0, $253 = 0, $254 = 0, $255 = 0, $256 = 0, $257 = 0, $258 = 0, $259 = 0, $26 = 0, $260 = 0, $261 = 0, $262 = 0, $263 = 0; var $264 = 0, $265 = 0, $266 = 0, $267 = 0, $268 = 0, $269 = 0, $27 = 0, $270 = 0, $271 = 0, $272 = 0, $273 = 0, $274 = 0, $275 = 0, $276 = 0, $277 = 0, $278 = 0, $279 = 0, $28 = 0, $280 = 0, $281 = 0; var $282 = 0, $283 = 0, $284 = 0, $285 = 0, $286 = 0, $287 = 0, $288 = 0, $289 = 0, $29 = 0, $290 = 0, $291 = 0, $292 = 0, $293 = 0, $294 = 0, $295 = 0, $296 = 0, $297 = 0, $298 = 0, $299 = 0, $3 = 0; var $30 = 0, $300 = 0, $301 = 0, $302 = 0, $303 = 0, $304 = 0, $305 = 0, $306 = 0, $307 = 0, $308 = 0, $309 = 0, $31 = 0, $310 = 0, $311 = 0, $312 = 0, $313 = 0, $314 = 0, $315 = 0, $316 = 0, $317 = 0; var $318 = 0, $319 = 0, $32 = 0, $320 = 0, $321 = 0, $322 = 0, $323 = 0, $324 = 0, $325 = 0, $326 = 0, $327 = 0, $328 = 0, $329 = 0, $33 = 0, $330 = 0, $331 = 0, $332 = 0, $333 = 0, $334 = 0, $335 = 0; var $336 = 0, $337 = 0, $338 = 0, $339 = 0, $34 = 0, $340 = 0, $341 = 0, $342 = 0, $343 = 0, $344 = 0, $345 = 0, $346 = 0, $347 = 0, $348 = 0, $349 = 0, $35 = 0, $350 = 0, $351 = 0, $352 = 0, $353 = 0; var $354 = 0, $355 = 0, $356 = 0, $357 = 0, $358 = 0, $359 = 0, $36 = 0, $360 = 0, $361 = 0, $362 = 0, $363 = 0, $364 = 0, $365 = 0, $366 = 0, $367 = 0, $368 = 0, $369 = 0, $37 = 0, $370 = 0, $371 = 0; var $372 = 0, $373 = 0, $374 = 0, $375 = 0, $376 = 0, $377 = 0, $378 = 0, $379 = 0, $38 = 0, $380 = 0, $381 = 0, $382 = 0, $383 = 0, $384 = 0, $385 = 0, $386 = 0, $387 = 0, $388 = 0, $389 = 0, $39 = 0; var $390 = 0, $391 = 0, $392 = 0, $393 = 0, $394 = 0, $395 = 0, $396 = 0, $397 = 0, $398 = 0, $399 = 0, $4 = 0, $40 = 0, $400 = 0, $401 = 0, $402 = 0, $403 = 0, $404 = 0, $405 = 0, $406 = 0, $407 = 0; var $408 = 0, $409 = 0, $41 = 0, $410 = 0, $411 = 0, $412 = 0, $413 = 0, $414 = 0, $415 = 0, $416 = 0, $417 = 0, $418 = 0, $419 = 0, $42 = 0, $420 = 0, $421 = 0, $422 = 0, $423 = 0, $424 = 0, $425 = 0; var $426 = 0, $427 = 0, $428 = 0, $429 = 0, $43 = 0, $430 = 0, $431 = 0, $432 = 0, $433 = 0, $434 = 0, $435 = 0, $436 = 0, $437 = 0, $438 = 0, $439 = 0, $44 = 0, $440 = 0, $441 = 0, $442 = 0, $443 = 0; var $444 = 0, $445 = 0, $446 = 0, $447 = 0, $448 = 0, $449 = 0, $45 = 0, $450 = 0, $451 = 0, $452 = 0, $453 = 0, $454 = 0, $455 = 0, $456 = 0, $457 = 0, $458 = 0, $459 = 0, $46 = 0, $460 = 0, $461 = 0; var $462 = 0, $463 = 0, $464 = 0, $465 = 0, $466 = 0, $467 = 0, $468 = 0, $469 = 0, $47 = 0, $470 = 0, $471 = 0, $472 = 0, $473 = 0, $474 = 0, $475 = 0, $476 = 0, $477 = 0, $478 = 0, $479 = 0, $48 = 0; var $480 = 0, $481 = 0, $482 = 0, $483 = 0, $484 = 0, $485 = 0, $486 = 0, $487 = 0, $488 = 0, $489 = 0, $49 = 0, $490 = 0, $491 = 0, $492 = 0, $493 = 0, $494 = 0, $495 = 0, $496 = 0, $497 = 0, $498 = 0; var $499 = 0, $5 = 0, $50 = 0, $500 = 0, $501 = 0, $502 = 0, $503 = 0, $504 = 0, $505 = 0, $506 = 0, $507 = 0, $508 = 0, $509 = 0, $51 = 0, $510 = 0, $511 = 0, $512 = 0, $513 = 0, $514 = 0, $515 = 0; var $516 = 0, $517 = 0, $518 = 0, $519 = 0, $52 = 0, $520 = 0, $521 = 0, $522 = 0, $523 = 0, $524 = 0, $525 = 0, $526 = 0, $527 = 0, $528 = 0, $529 = 0, $53 = 0, $530 = 0, $531 = 0, $532 = 0, $533 = 0; var $534 = 0, $535 = 0, $536 = 0, $537 = 0, $538 = 0, $539 = 0, $54 = 0, $540 = 0, $541 = 0, $542 = 0, $543 = 0, $544 = 0, $545 = 0, $546 = 0, $547 = 0, $548 = 0, $549 = 0, $55 = 0, $550 = 0, $551 = 0; var $552 = 0, $553 = 0, $554 = 0, $555 = 0, $556 = 0, $557 = 0, $558 = 0, $559 = 0, $56 = 0, $560 = 0, $561 = 0, $562 = 0, $563 = 0, $564 = 0, $565 = 0, $566 = 0, $567 = 0, $568 = 0, $569 = 0, $57 = 0; var $570 = 0, $571 = 0, $572 = 0, $573 = 0, $574 = 0, $575 = 0, $576 = 0, $577 = 0, $578 = 0, $579 = 0, $58 = 0, $580 = 0, $581 = 0, $582 = 0, $583 = 0, $584 = 0, $585 = 0, $586 = 0, $587 = 0, $588 = 0; var $589 = 0, $59 = 0, $590 = 0, $591 = 0, $592 = 0, $593 = 0, $594 = 0, $595 = 0, $596 = 0, $597 = 0, $598 = 0, $599 = 0, $6 = 0, $60 = 0, $600 = 0, $601 = 0, $602 = 0, $603 = 0, $604 = 0, $605 = 0; var $606 = 0, $607 = 0, $608 = 0, $609 = 0, $61 = 0, $610 = 0, $611 = 0, $612 = 0, $613 = 0, $614 = 0, $615 = 0, $616 = 0, $617 = 0, $618 = 0, $619 = 0, $62 = 0, $620 = 0, $621 = 0, $622 = 0, $623 = 0; var $624 = 0, $625 = 0, $626 = 0, $627 = 0, $628 = 0, $629 = 0, $63 = 0, $630 = 0, $631 = 0, $632 = 0, $633 = 0, $634 = 0, $635 = 0, $636 = 0, $637 = 0, $638 = 0, $639 = 0, $64 = 0, $640 = 0, $641 = 0; var $642 = 0, $643 = 0, $644 = 0, $645 = 0, $646 = 0, $647 = 0, $648 = 0, $649 = 0, $65 = 0, $650 = 0, $651 = 0, $652 = 0, $653 = 0, $654 = 0, $655 = 0, $656 = 0, $657 = 0, $658 = 0, $659 = 0, $66 = 0; var $660 = 0, $661 = 0, $662 = 0, $663 = 0, $664 = 0, $665 = 0, $666 = 0, $667 = 0, $668 = 0, $669 = 0, $67 = 0, $670 = 0, $671 = 0, $672 = 0, $673 = 0, $674 = 0, $675 = 0, $676 = 0, $677 = 0, $678 = 0; var $679 = 0, $68 = 0, $680 = 0, $681 = 0, $682 = 0, $683 = 0, $684 = 0, $685 = 0, $686 = 0, $687 = 0, $688 = 0, $689 = 0, $69 = 0, $690 = 0, $691 = 0, $692 = 0, $693 = 0, $694 = 0, $695 = 0, $696 = 0; var $697 = 0, $698 = 0, $699 = 0, $7 = 0, $70 = 0, $700 = 0, $701 = 0, $702 = 0, $703 = 0, $704 = 0, $705 = 0, $706 = 0, $707 = 0, $708 = 0, $709 = 0, $71 = 0, $710 = 0, $711 = 0, $712 = 0, $713 = 0; var $714 = 0, $715 = 0, $716 = 0, $717 = 0, $718 = 0, $719 = 0, $72 = 0, $720 = 0, $721 = 0, $722 = 0, $723 = 0, $724 = 0, $725 = 0, $726 = 0, $727 = 0, $728 = 0, $729 = 0, $73 = 0, $730 = 0, $731 = 0; var $732 = 0, $733 = 0, $734 = 0, $735 = 0, $736 = 0, $737 = 0, $738 = 0, $739 = 0, $74 = 0, $740 = 0, $741 = 0, $742 = 0, $743 = 0, $744 = 0, $745 = 0, $746 = 0, $747 = 0, $748 = 0, $749 = 0, $75 = 0; var $750 = 0, $751 = 0, $752 = 0, $753 = 0, $754 = 0, $755 = 0, $756 = 0, $757 = 0, $758 = 0, $759 = 0, $76 = 0, $760 = 0, $761 = 0, $762 = 0, $763 = 0, $764 = 0, $765 = 0, $766 = 0, $767 = 0, $768 = 0; var $769 = 0, $77 = 0, $770 = 0, $771 = 0, $772 = 0, $773 = 0, $774 = 0, $775 = 0, $776 = 0, $777 = 0, $778 = 0, $779 = 0, $78 = 0, $780 = 0, $781 = 0, $782 = 0, $783 = 0, $784 = 0, $785 = 0, $786 = 0; var $787 = 0, $788 = 0, $789 = 0, $79 = 0, $790 = 0, $791 = 0, $792 = 0, $793 = 0, $794 = 0, $795 = 0, $796 = 0, $797 = 0, $798 = 0, $799 = 0, $8 = 0, $80 = 0, $800 = 0, $801 = 0, $802 = 0, $803 = 0; var $804 = 0, $805 = 0, $806 = 0, $807 = 0, $808 = 0, $809 = 0, $81 = 0, $810 = 0, $811 = 0, $812 = 0, $813 = 0, $814 = 0, $815 = 0, $816 = 0, $817 = 0, $818 = 0, $819 = 0, $82 = 0, $820 = 0, $821 = 0; var $822 = 0, $823 = 0, $824 = 0, $825 = 0, $826 = 0, $827 = 0, $828 = 0, $829 = 0, $83 = 0, $830 = 0, $831 = 0, $832 = 0, $833 = 0, $834 = 0, $835 = 0, $836 = 0, $837 = 0, $838 = 0, $839 = 0, $84 = 0; var $840 = 0, $841 = 0, $842 = 0, $843 = 0, $844 = 0, $845 = 0, $846 = 0, $847 = 0, $848 = 0, $849 = 0, $85 = 0, $850 = 0, $851 = 0, $852 = 0, $853 = 0, $854 = 0, $855 = 0, $856 = 0, $857 = 0, $858 = 0; var $859 = 0, $86 = 0, $860 = 0, $861 = 0, $862 = 0, $863 = 0, $864 = 0, $865 = 0, $866 = 0, $867 = 0, $868 = 0, $869 = 0, $87 = 0, $870 = 0, $871 = 0, $872 = 0, $873 = 0, $874 = 0, $875 = 0, $876 = 0; var $877 = 0, $878 = 0, $879 = 0, $88 = 0, $880 = 0, $881 = 0, $882 = 0, $883 = 0, $884 = 0, $885 = 0, $886 = 0, $887 = 0, $888 = 0, $889 = 0, $89 = 0, $890 = 0, $891 = 0, $892 = 0, $893 = 0, $894 = 0; var $895 = 0, $896 = 0, $897 = 0, $898 = 0, $899 = 0, $9 = 0, $90 = 0, $900 = 0, $901 = 0, $902 = 0, $903 = 0, $904 = 0, $905 = 0, $906 = 0, $907 = 0, $908 = 0, $909 = 0, $91 = 0, $910 = 0, $911 = 0; var $912 = 0, $913 = 0, $914 = 0, $915 = 0, $916 = 0, $917 = 0, $918 = 0, $919 = 0, $92 = 0, $920 = 0, $921 = 0, $922 = 0, $923 = 0, $924 = 0, $925 = 0, $926 = 0, $927 = 0, $928 = 0, $929 = 0, $93 = 0; var $930 = 0, $931 = 0, $932 = 0, $933 = 0, $934 = 0, $935 = 0, $936 = 0, $937 = 0, $938 = 0, $939 = 0, $94 = 0, $940 = 0, $941 = 0, $942 = 0, $943 = 0, $944 = 0, $945 = 0, $946 = 0, $947 = 0, $948 = 0; var $949 = 0, $95 = 0, $950 = 0, $951 = 0, $952 = 0, $953 = 0, $954 = 0, $955 = 0, $956 = 0, $957 = 0, $958 = 0, $959 = 0, $96 = 0, $960 = 0, $961 = 0, $962 = 0, $963 = 0, $964 = 0, $965 = 0, $966 = 0; var $967 = 0, $968 = 0, $969 = 0, $97 = 0, $970 = 0, $971 = 0, $972 = 0, $973 = 0, $974 = 0, $975 = 0, $976 = 0, $977 = 0, $978 = 0, $979 = 0, $98 = 0, $980 = 0, $981 = 0, $982 = 0, $983 = 0, $984 = 0; var $985 = 0, $986 = 0, $987 = 0, $988 = 0, $989 = 0, $99 = 0, $990 = 0, $991 = 0, $992 = 0, $993 = 0, $994 = 0, $995 = 0, $996 = 0, $997 = 0, $998 = 0, $999 = 0, $F$0$i$i = 0, $F1$0$i = 0, $F4$0 = 0, $F4$0$i$i = 0; var $F5$0$i = 0, $I1$0$i$i = 0, $I7$0$i = 0, $I7$0$i$i = 0, $K12$029$i = 0, $K2$07$i$i = 0, $K8$051$i$i = 0, $R$0$i = 0, $R$0$i$i = 0, $R$0$i$i$lcssa = 0, $R$0$i$lcssa = 0, $R$0$i18 = 0, $R$0$i18$lcssa = 0, $R$1$i = 0, $R$1$i$i = 0, $R$1$i20 = 0, $RP$0$i = 0, $RP$0$i$i = 0, $RP$0$i$i$lcssa = 0, $RP$0$i$lcssa = 0; var $RP$0$i17 = 0, $RP$0$i17$lcssa = 0, $T$0$lcssa$i = 0, $T$0$lcssa$i$i = 0, $T$0$lcssa$i25$i = 0, $T$028$i = 0, $T$028$i$lcssa = 0, $T$050$i$i = 0, $T$050$i$i$lcssa = 0, $T$06$i$i = 0, $T$06$i$i$lcssa = 0, $br$0$ph$i = 0, $cond$i = 0, $cond$i$i = 0, $cond$i21 = 0, $exitcond$i$i = 0, $i$02$i$i = 0, $idx$0$i = 0, $mem$0 = 0, $nb$0 = 0; var $not$$i = 0, $not$$i$i = 0, $not$$i26$i = 0, $oldfirst$0$i$i = 0, $or$cond$i = 0, $or$cond$i30 = 0, $or$cond1$i = 0, $or$cond19$i = 0, $or$cond2$i = 0, $or$cond3$i = 0, $or$cond5$i = 0, $or$cond57$i = 0, $or$cond6$i = 0, $or$cond8$i = 0, $or$cond9$i = 0, $qsize$0$i$i = 0, $rsize$0$i = 0, $rsize$0$i$lcssa = 0, $rsize$0$i15 = 0, $rsize$1$i = 0; var $rsize$2$i = 0, $rsize$3$lcssa$i = 0, $rsize$331$i = 0, $rst$0$i = 0, $rst$1$i = 0, $sizebits$0$i = 0, $sp$0$i$i = 0, $sp$0$i$i$i = 0, $sp$084$i = 0, $sp$084$i$lcssa = 0, $sp$183$i = 0, $sp$183$i$lcssa = 0, $ssize$0$$i = 0, $ssize$0$i = 0, $ssize$1$ph$i = 0, $ssize$2$i = 0, $t$0$i = 0, $t$0$i14 = 0, $t$1$i = 0, $t$2$ph$i = 0; var $t$2$v$3$i = 0, $t$230$i = 0, $tbase$255$i = 0, $tsize$0$ph$i = 0, $tsize$0323944$i = 0, $tsize$1$i = 0, $tsize$254$i = 0, $v$0$i = 0, $v$0$i$lcssa = 0, $v$0$i16 = 0, $v$1$i = 0, $v$2$i = 0, $v$3$lcssa$i = 0, $v$3$ph$i = 0, $v$332$i = 0, label = 0, sp = 0; sp = STACKTOP; $0 = ($bytes>>>0)<(245); do { if ($0) { $1 = ($bytes>>>0)<(11); $2 = (($bytes) + 11)|0; $3 = $2 & -8; $4 = $1 ? 16 : $3; $5 = $4 >>> 3; $6 = HEAP32[812>>2]|0; $7 = $6 >>> $5; $8 = $7 & 3; $9 = ($8|0)==(0); if (!($9)) { $10 = $7 & 1; $11 = $10 ^ 1; $12 = (($11) + ($5))|0; $13 = $12 << 1; $14 = (852 + ($13<<2)|0); $$sum10 = (($13) + 2)|0; $15 = (852 + ($$sum10<<2)|0); $16 = HEAP32[$15>>2]|0; $17 = ((($16)) + 8|0); $18 = HEAP32[$17>>2]|0; $19 = ($14|0)==($18|0); do { if ($19) { $20 = 1 << $12; $21 = $20 ^ -1; $22 = $6 & $21; HEAP32[812>>2] = $22; } else { $23 = HEAP32[(828)>>2]|0; $24 = ($18>>>0)<($23>>>0); if ($24) { _abort(); // unreachable; } $25 = ((($18)) + 12|0); $26 = HEAP32[$25>>2]|0; $27 = ($26|0)==($16|0); if ($27) { HEAP32[$25>>2] = $14; HEAP32[$15>>2] = $18; break; } else { _abort(); // unreachable; } } } while(0); $28 = $12 << 3; $29 = $28 | 3; $30 = ((($16)) + 4|0); HEAP32[$30>>2] = $29; $$sum1112 = $28 | 4; $31 = (($16) + ($$sum1112)|0); $32 = HEAP32[$31>>2]|0; $33 = $32 | 1; HEAP32[$31>>2] = $33; $mem$0 = $17; return ($mem$0|0); } $34 = HEAP32[(820)>>2]|0; $35 = ($4>>>0)>($34>>>0); if ($35) { $36 = ($7|0)==(0); if (!($36)) { $37 = $7 << $5; $38 = 2 << $5; $39 = (0 - ($38))|0; $40 = $38 | $39; $41 = $37 & $40; $42 = (0 - ($41))|0; $43 = $41 & $42; $44 = (($43) + -1)|0; $45 = $44 >>> 12; $46 = $45 & 16; $47 = $44 >>> $46; $48 = $47 >>> 5; $49 = $48 & 8; $50 = $49 | $46; $51 = $47 >>> $49; $52 = $51 >>> 2; $53 = $52 & 4; $54 = $50 | $53; $55 = $51 >>> $53; $56 = $55 >>> 1; $57 = $56 & 2; $58 = $54 | $57; $59 = $55 >>> $57; $60 = $59 >>> 1; $61 = $60 & 1; $62 = $58 | $61; $63 = $59 >>> $61; $64 = (($62) + ($63))|0; $65 = $64 << 1; $66 = (852 + ($65<<2)|0); $$sum4 = (($65) + 2)|0; $67 = (852 + ($$sum4<<2)|0); $68 = HEAP32[$67>>2]|0; $69 = ((($68)) + 8|0); $70 = HEAP32[$69>>2]|0; $71 = ($66|0)==($70|0); do { if ($71) { $72 = 1 << $64; $73 = $72 ^ -1; $74 = $6 & $73; HEAP32[812>>2] = $74; $88 = $34; } else { $75 = HEAP32[(828)>>2]|0; $76 = ($70>>>0)<($75>>>0); if ($76) { _abort(); // unreachable; } $77 = ((($70)) + 12|0); $78 = HEAP32[$77>>2]|0; $79 = ($78|0)==($68|0); if ($79) { HEAP32[$77>>2] = $66; HEAP32[$67>>2] = $70; $$pre = HEAP32[(820)>>2]|0; $88 = $$pre; break; } else { _abort(); // unreachable; } } } while(0); $80 = $64 << 3; $81 = (($80) - ($4))|0; $82 = $4 | 3; $83 = ((($68)) + 4|0); HEAP32[$83>>2] = $82; $84 = (($68) + ($4)|0); $85 = $81 | 1; $$sum56 = $4 | 4; $86 = (($68) + ($$sum56)|0); HEAP32[$86>>2] = $85; $87 = (($68) + ($80)|0); HEAP32[$87>>2] = $81; $89 = ($88|0)==(0); if (!($89)) { $90 = HEAP32[(832)>>2]|0; $91 = $88 >>> 3; $92 = $91 << 1; $93 = (852 + ($92<<2)|0); $94 = HEAP32[812>>2]|0; $95 = 1 << $91; $96 = $94 & $95; $97 = ($96|0)==(0); if ($97) { $98 = $94 | $95; HEAP32[812>>2] = $98; $$pre105 = (($92) + 2)|0; $$pre106 = (852 + ($$pre105<<2)|0); $$pre$phiZ2D = $$pre106;$F4$0 = $93; } else { $$sum9 = (($92) + 2)|0; $99 = (852 + ($$sum9<<2)|0); $100 = HEAP32[$99>>2]|0; $101 = HEAP32[(828)>>2]|0; $102 = ($100>>>0)<($101>>>0); if ($102) { _abort(); // unreachable; } else { $$pre$phiZ2D = $99;$F4$0 = $100; } } HEAP32[$$pre$phiZ2D>>2] = $90; $103 = ((($F4$0)) + 12|0); HEAP32[$103>>2] = $90; $104 = ((($90)) + 8|0); HEAP32[$104>>2] = $F4$0; $105 = ((($90)) + 12|0); HEAP32[$105>>2] = $93; } HEAP32[(820)>>2] = $81; HEAP32[(832)>>2] = $84; $mem$0 = $69; return ($mem$0|0); } $106 = HEAP32[(816)>>2]|0; $107 = ($106|0)==(0); if ($107) { $nb$0 = $4; } else { $108 = (0 - ($106))|0; $109 = $106 & $108; $110 = (($109) + -1)|0; $111 = $110 >>> 12; $112 = $111 & 16; $113 = $110 >>> $112; $114 = $113 >>> 5; $115 = $114 & 8; $116 = $115 | $112; $117 = $113 >>> $115; $118 = $117 >>> 2; $119 = $118 & 4; $120 = $116 | $119; $121 = $117 >>> $119; $122 = $121 >>> 1; $123 = $122 & 2; $124 = $120 | $123; $125 = $121 >>> $123; $126 = $125 >>> 1; $127 = $126 & 1; $128 = $124 | $127; $129 = $125 >>> $127; $130 = (($128) + ($129))|0; $131 = (1116 + ($130<<2)|0); $132 = HEAP32[$131>>2]|0; $133 = ((($132)) + 4|0); $134 = HEAP32[$133>>2]|0; $135 = $134 & -8; $136 = (($135) - ($4))|0; $rsize$0$i = $136;$t$0$i = $132;$v$0$i = $132; while(1) { $137 = ((($t$0$i)) + 16|0); $138 = HEAP32[$137>>2]|0; $139 = ($138|0)==(0|0); if ($139) { $140 = ((($t$0$i)) + 20|0); $141 = HEAP32[$140>>2]|0; $142 = ($141|0)==(0|0); if ($142) { $rsize$0$i$lcssa = $rsize$0$i;$v$0$i$lcssa = $v$0$i; break; } else { $144 = $141; } } else { $144 = $138; } $143 = ((($144)) + 4|0); $145 = HEAP32[$143>>2]|0; $146 = $145 & -8; $147 = (($146) - ($4))|0; $148 = ($147>>>0)<($rsize$0$i>>>0); $$rsize$0$i = $148 ? $147 : $rsize$0$i; $$v$0$i = $148 ? $144 : $v$0$i; $rsize$0$i = $$rsize$0$i;$t$0$i = $144;$v$0$i = $$v$0$i; } $149 = HEAP32[(828)>>2]|0; $150 = ($v$0$i$lcssa>>>0)<($149>>>0); if ($150) { _abort(); // unreachable; } $151 = (($v$0$i$lcssa) + ($4)|0); $152 = ($v$0$i$lcssa>>>0)<($151>>>0); if (!($152)) { _abort(); // unreachable; } $153 = ((($v$0$i$lcssa)) + 24|0); $154 = HEAP32[$153>>2]|0; $155 = ((($v$0$i$lcssa)) + 12|0); $156 = HEAP32[$155>>2]|0; $157 = ($156|0)==($v$0$i$lcssa|0); do { if ($157) { $167 = ((($v$0$i$lcssa)) + 20|0); $168 = HEAP32[$167>>2]|0; $169 = ($168|0)==(0|0); if ($169) { $170 = ((($v$0$i$lcssa)) + 16|0); $171 = HEAP32[$170>>2]|0; $172 = ($171|0)==(0|0); if ($172) { $R$1$i = 0; break; } else { $R$0$i = $171;$RP$0$i = $170; } } else { $R$0$i = $168;$RP$0$i = $167; } while(1) { $173 = ((($R$0$i)) + 20|0); $174 = HEAP32[$173>>2]|0; $175 = ($174|0)==(0|0); if (!($175)) { $R$0$i = $174;$RP$0$i = $173; continue; } $176 = ((($R$0$i)) + 16|0); $177 = HEAP32[$176>>2]|0; $178 = ($177|0)==(0|0); if ($178) { $R$0$i$lcssa = $R$0$i;$RP$0$i$lcssa = $RP$0$i; break; } else { $R$0$i = $177;$RP$0$i = $176; } } $179 = ($RP$0$i$lcssa>>>0)<($149>>>0); if ($179) { _abort(); // unreachable; } else { HEAP32[$RP$0$i$lcssa>>2] = 0; $R$1$i = $R$0$i$lcssa; break; } } else { $158 = ((($v$0$i$lcssa)) + 8|0); $159 = HEAP32[$158>>2]|0; $160 = ($159>>>0)<($149>>>0); if ($160) { _abort(); // unreachable; } $161 = ((($159)) + 12|0); $162 = HEAP32[$161>>2]|0; $163 = ($162|0)==($v$0$i$lcssa|0); if (!($163)) { _abort(); // unreachable; } $164 = ((($156)) + 8|0); $165 = HEAP32[$164>>2]|0; $166 = ($165|0)==($v$0$i$lcssa|0); if ($166) { HEAP32[$161>>2] = $156; HEAP32[$164>>2] = $159; $R$1$i = $156; break; } else { _abort(); // unreachable; } } } while(0); $180 = ($154|0)==(0|0); do { if (!($180)) { $181 = ((($v$0$i$lcssa)) + 28|0); $182 = HEAP32[$181>>2]|0; $183 = (1116 + ($182<<2)|0); $184 = HEAP32[$183>>2]|0; $185 = ($v$0$i$lcssa|0)==($184|0); if ($185) { HEAP32[$183>>2] = $R$1$i; $cond$i = ($R$1$i|0)==(0|0); if ($cond$i) { $186 = 1 << $182; $187 = $186 ^ -1; $188 = HEAP32[(816)>>2]|0; $189 = $188 & $187; HEAP32[(816)>>2] = $189; break; } } else { $190 = HEAP32[(828)>>2]|0; $191 = ($154>>>0)<($190>>>0); if ($191) { _abort(); // unreachable; } $192 = ((($154)) + 16|0); $193 = HEAP32[$192>>2]|0; $194 = ($193|0)==($v$0$i$lcssa|0); if ($194) { HEAP32[$192>>2] = $R$1$i; } else { $195 = ((($154)) + 20|0); HEAP32[$195>>2] = $R$1$i; } $196 = ($R$1$i|0)==(0|0); if ($196) { break; } } $197 = HEAP32[(828)>>2]|0; $198 = ($R$1$i>>>0)<($197>>>0); if ($198) { _abort(); // unreachable; } $199 = ((($R$1$i)) + 24|0); HEAP32[$199>>2] = $154; $200 = ((($v$0$i$lcssa)) + 16|0); $201 = HEAP32[$200>>2]|0; $202 = ($201|0)==(0|0); do { if (!($202)) { $203 = ($201>>>0)<($197>>>0); if ($203) { _abort(); // unreachable; } else { $204 = ((($R$1$i)) + 16|0); HEAP32[$204>>2] = $201; $205 = ((($201)) + 24|0); HEAP32[$205>>2] = $R$1$i; break; } } } while(0); $206 = ((($v$0$i$lcssa)) + 20|0); $207 = HEAP32[$206>>2]|0; $208 = ($207|0)==(0|0); if (!($208)) { $209 = HEAP32[(828)>>2]|0; $210 = ($207>>>0)<($209>>>0); if ($210) { _abort(); // unreachable; } else { $211 = ((($R$1$i)) + 20|0); HEAP32[$211>>2] = $207; $212 = ((($207)) + 24|0); HEAP32[$212>>2] = $R$1$i; break; } } } } while(0); $213 = ($rsize$0$i$lcssa>>>0)<(16); if ($213) { $214 = (($rsize$0$i$lcssa) + ($4))|0; $215 = $214 | 3; $216 = ((($v$0$i$lcssa)) + 4|0); HEAP32[$216>>2] = $215; $$sum4$i = (($214) + 4)|0; $217 = (($v$0$i$lcssa) + ($$sum4$i)|0); $218 = HEAP32[$217>>2]|0; $219 = $218 | 1; HEAP32[$217>>2] = $219; } else { $220 = $4 | 3; $221 = ((($v$0$i$lcssa)) + 4|0); HEAP32[$221>>2] = $220; $222 = $rsize$0$i$lcssa | 1; $$sum$i35 = $4 | 4; $223 = (($v$0$i$lcssa) + ($$sum$i35)|0); HEAP32[$223>>2] = $222; $$sum1$i = (($rsize$0$i$lcssa) + ($4))|0; $224 = (($v$0$i$lcssa) + ($$sum1$i)|0); HEAP32[$224>>2] = $rsize$0$i$lcssa; $225 = HEAP32[(820)>>2]|0; $226 = ($225|0)==(0); if (!($226)) { $227 = HEAP32[(832)>>2]|0; $228 = $225 >>> 3; $229 = $228 << 1; $230 = (852 + ($229<<2)|0); $231 = HEAP32[812>>2]|0; $232 = 1 << $228; $233 = $231 & $232; $234 = ($233|0)==(0); if ($234) { $235 = $231 | $232; HEAP32[812>>2] = $235; $$pre$i = (($229) + 2)|0; $$pre8$i = (852 + ($$pre$i<<2)|0); $$pre$phi$iZ2D = $$pre8$i;$F1$0$i = $230; } else { $$sum3$i = (($229) + 2)|0; $236 = (852 + ($$sum3$i<<2)|0); $237 = HEAP32[$236>>2]|0; $238 = HEAP32[(828)>>2]|0; $239 = ($237>>>0)<($238>>>0); if ($239) { _abort(); // unreachable; } else { $$pre$phi$iZ2D = $236;$F1$0$i = $237; } } HEAP32[$$pre$phi$iZ2D>>2] = $227; $240 = ((($F1$0$i)) + 12|0); HEAP32[$240>>2] = $227; $241 = ((($227)) + 8|0); HEAP32[$241>>2] = $F1$0$i; $242 = ((($227)) + 12|0); HEAP32[$242>>2] = $230; } HEAP32[(820)>>2] = $rsize$0$i$lcssa; HEAP32[(832)>>2] = $151; } $243 = ((($v$0$i$lcssa)) + 8|0); $mem$0 = $243; return ($mem$0|0); } } else { $nb$0 = $4; } } else { $244 = ($bytes>>>0)>(4294967231); if ($244) { $nb$0 = -1; } else { $245 = (($bytes) + 11)|0; $246 = $245 & -8; $247 = HEAP32[(816)>>2]|0; $248 = ($247|0)==(0); if ($248) { $nb$0 = $246; } else { $249 = (0 - ($246))|0; $250 = $245 >>> 8; $251 = ($250|0)==(0); if ($251) { $idx$0$i = 0; } else { $252 = ($246>>>0)>(16777215); if ($252) { $idx$0$i = 31; } else { $253 = (($250) + 1048320)|0; $254 = $253 >>> 16; $255 = $254 & 8; $256 = $250 << $255; $257 = (($256) + 520192)|0; $258 = $257 >>> 16; $259 = $258 & 4; $260 = $259 | $255; $261 = $256 << $259; $262 = (($261) + 245760)|0; $263 = $262 >>> 16; $264 = $263 & 2; $265 = $260 | $264; $266 = (14 - ($265))|0; $267 = $261 << $264; $268 = $267 >>> 15; $269 = (($266) + ($268))|0; $270 = $269 << 1; $271 = (($269) + 7)|0; $272 = $246 >>> $271; $273 = $272 & 1; $274 = $273 | $270; $idx$0$i = $274; } } $275 = (1116 + ($idx$0$i<<2)|0); $276 = HEAP32[$275>>2]|0; $277 = ($276|0)==(0|0); L123: do { if ($277) { $rsize$2$i = $249;$t$1$i = 0;$v$2$i = 0; label = 86; } else { $278 = ($idx$0$i|0)==(31); $279 = $idx$0$i >>> 1; $280 = (25 - ($279))|0; $281 = $278 ? 0 : $280; $282 = $246 << $281; $rsize$0$i15 = $249;$rst$0$i = 0;$sizebits$0$i = $282;$t$0$i14 = $276;$v$0$i16 = 0; while(1) { $283 = ((($t$0$i14)) + 4|0); $284 = HEAP32[$283>>2]|0; $285 = $284 & -8; $286 = (($285) - ($246))|0; $287 = ($286>>>0)<($rsize$0$i15>>>0); if ($287) { $288 = ($285|0)==($246|0); if ($288) { $rsize$331$i = $286;$t$230$i = $t$0$i14;$v$332$i = $t$0$i14; label = 90; break L123; } else { $rsize$1$i = $286;$v$1$i = $t$0$i14; } } else { $rsize$1$i = $rsize$0$i15;$v$1$i = $v$0$i16; } $289 = ((($t$0$i14)) + 20|0); $290 = HEAP32[$289>>2]|0; $291 = $sizebits$0$i >>> 31; $292 = (((($t$0$i14)) + 16|0) + ($291<<2)|0); $293 = HEAP32[$292>>2]|0; $294 = ($290|0)==(0|0); $295 = ($290|0)==($293|0); $or$cond19$i = $294 | $295; $rst$1$i = $or$cond19$i ? $rst$0$i : $290; $296 = ($293|0)==(0|0); $297 = $sizebits$0$i << 1; if ($296) { $rsize$2$i = $rsize$1$i;$t$1$i = $rst$1$i;$v$2$i = $v$1$i; label = 86; break; } else { $rsize$0$i15 = $rsize$1$i;$rst$0$i = $rst$1$i;$sizebits$0$i = $297;$t$0$i14 = $293;$v$0$i16 = $v$1$i; } } } } while(0); if ((label|0) == 86) { $298 = ($t$1$i|0)==(0|0); $299 = ($v$2$i|0)==(0|0); $or$cond$i = $298 & $299; if ($or$cond$i) { $300 = 2 << $idx$0$i; $301 = (0 - ($300))|0; $302 = $300 | $301; $303 = $247 & $302; $304 = ($303|0)==(0); if ($304) { $nb$0 = $246; break; } $305 = (0 - ($303))|0; $306 = $303 & $305; $307 = (($306) + -1)|0; $308 = $307 >>> 12; $309 = $308 & 16; $310 = $307 >>> $309; $311 = $310 >>> 5; $312 = $311 & 8; $313 = $312 | $309; $314 = $310 >>> $312; $315 = $314 >>> 2; $316 = $315 & 4; $317 = $313 | $316; $318 = $314 >>> $316; $319 = $318 >>> 1; $320 = $319 & 2; $321 = $317 | $320; $322 = $318 >>> $320; $323 = $322 >>> 1; $324 = $323 & 1; $325 = $321 | $324; $326 = $322 >>> $324; $327 = (($325) + ($326))|0; $328 = (1116 + ($327<<2)|0); $329 = HEAP32[$328>>2]|0; $t$2$ph$i = $329;$v$3$ph$i = 0; } else { $t$2$ph$i = $t$1$i;$v$3$ph$i = $v$2$i; } $330 = ($t$2$ph$i|0)==(0|0); if ($330) { $rsize$3$lcssa$i = $rsize$2$i;$v$3$lcssa$i = $v$3$ph$i; } else { $rsize$331$i = $rsize$2$i;$t$230$i = $t$2$ph$i;$v$332$i = $v$3$ph$i; label = 90; } } if ((label|0) == 90) { while(1) { label = 0; $331 = ((($t$230$i)) + 4|0); $332 = HEAP32[$331>>2]|0; $333 = $332 & -8; $334 = (($333) - ($246))|0; $335 = ($334>>>0)<($rsize$331$i>>>0); $$rsize$3$i = $335 ? $334 : $rsize$331$i; $t$2$v$3$i = $335 ? $t$230$i : $v$332$i; $336 = ((($t$230$i)) + 16|0); $337 = HEAP32[$336>>2]|0; $338 = ($337|0)==(0|0); if (!($338)) { $rsize$331$i = $$rsize$3$i;$t$230$i = $337;$v$332$i = $t$2$v$3$i; label = 90; continue; } $339 = ((($t$230$i)) + 20|0); $340 = HEAP32[$339>>2]|0; $341 = ($340|0)==(0|0); if ($341) { $rsize$3$lcssa$i = $$rsize$3$i;$v$3$lcssa$i = $t$2$v$3$i; break; } else { $rsize$331$i = $$rsize$3$i;$t$230$i = $340;$v$332$i = $t$2$v$3$i; label = 90; } } } $342 = ($v$3$lcssa$i|0)==(0|0); if ($342) { $nb$0 = $246; } else { $343 = HEAP32[(820)>>2]|0; $344 = (($343) - ($246))|0; $345 = ($rsize$3$lcssa$i>>>0)<($344>>>0); if ($345) { $346 = HEAP32[(828)>>2]|0; $347 = ($v$3$lcssa$i>>>0)<($346>>>0); if ($347) { _abort(); // unreachable; } $348 = (($v$3$lcssa$i) + ($246)|0); $349 = ($v$3$lcssa$i>>>0)<($348>>>0); if (!($349)) { _abort(); // unreachable; } $350 = ((($v$3$lcssa$i)) + 24|0); $351 = HEAP32[$350>>2]|0; $352 = ((($v$3$lcssa$i)) + 12|0); $353 = HEAP32[$352>>2]|0; $354 = ($353|0)==($v$3$lcssa$i|0); do { if ($354) { $364 = ((($v$3$lcssa$i)) + 20|0); $365 = HEAP32[$364>>2]|0; $366 = ($365|0)==(0|0); if ($366) { $367 = ((($v$3$lcssa$i)) + 16|0); $368 = HEAP32[$367>>2]|0; $369 = ($368|0)==(0|0); if ($369) { $R$1$i20 = 0; break; } else { $R$0$i18 = $368;$RP$0$i17 = $367; } } else { $R$0$i18 = $365;$RP$0$i17 = $364; } while(1) { $370 = ((($R$0$i18)) + 20|0); $371 = HEAP32[$370>>2]|0; $372 = ($371|0)==(0|0); if (!($372)) { $R$0$i18 = $371;$RP$0$i17 = $370; continue; } $373 = ((($R$0$i18)) + 16|0); $374 = HEAP32[$373>>2]|0; $375 = ($374|0)==(0|0); if ($375) { $R$0$i18$lcssa = $R$0$i18;$RP$0$i17$lcssa = $RP$0$i17; break; } else { $R$0$i18 = $374;$RP$0$i17 = $373; } } $376 = ($RP$0$i17$lcssa>>>0)<($346>>>0); if ($376) { _abort(); // unreachable; } else { HEAP32[$RP$0$i17$lcssa>>2] = 0; $R$1$i20 = $R$0$i18$lcssa; break; } } else { $355 = ((($v$3$lcssa$i)) + 8|0); $356 = HEAP32[$355>>2]|0; $357 = ($356>>>0)<($346>>>0); if ($357) { _abort(); // unreachable; } $358 = ((($356)) + 12|0); $359 = HEAP32[$358>>2]|0; $360 = ($359|0)==($v$3$lcssa$i|0); if (!($360)) { _abort(); // unreachable; } $361 = ((($353)) + 8|0); $362 = HEAP32[$361>>2]|0; $363 = ($362|0)==($v$3$lcssa$i|0); if ($363) { HEAP32[$358>>2] = $353; HEAP32[$361>>2] = $356; $R$1$i20 = $353; break; } else { _abort(); // unreachable; } } } while(0); $377 = ($351|0)==(0|0); do { if (!($377)) { $378 = ((($v$3$lcssa$i)) + 28|0); $379 = HEAP32[$378>>2]|0; $380 = (1116 + ($379<<2)|0); $381 = HEAP32[$380>>2]|0; $382 = ($v$3$lcssa$i|0)==($381|0); if ($382) { HEAP32[$380>>2] = $R$1$i20; $cond$i21 = ($R$1$i20|0)==(0|0); if ($cond$i21) { $383 = 1 << $379; $384 = $383 ^ -1; $385 = HEAP32[(816)>>2]|0; $386 = $385 & $384; HEAP32[(816)>>2] = $386; break; } } else { $387 = HEAP32[(828)>>2]|0; $388 = ($351>>>0)<($387>>>0); if ($388) { _abort(); // unreachable; } $389 = ((($351)) + 16|0); $390 = HEAP32[$389>>2]|0; $391 = ($390|0)==($v$3$lcssa$i|0); if ($391) { HEAP32[$389>>2] = $R$1$i20; } else { $392 = ((($351)) + 20|0); HEAP32[$392>>2] = $R$1$i20; } $393 = ($R$1$i20|0)==(0|0); if ($393) { break; } } $394 = HEAP32[(828)>>2]|0; $395 = ($R$1$i20>>>0)<($394>>>0); if ($395) { _abort(); // unreachable; } $396 = ((($R$1$i20)) + 24|0); HEAP32[$396>>2] = $351; $397 = ((($v$3$lcssa$i)) + 16|0); $398 = HEAP32[$397>>2]|0; $399 = ($398|0)==(0|0); do { if (!($399)) { $400 = ($398>>>0)<($394>>>0); if ($400) { _abort(); // unreachable; } else { $401 = ((($R$1$i20)) + 16|0); HEAP32[$401>>2] = $398; $402 = ((($398)) + 24|0); HEAP32[$402>>2] = $R$1$i20; break; } } } while(0); $403 = ((($v$3$lcssa$i)) + 20|0); $404 = HEAP32[$403>>2]|0; $405 = ($404|0)==(0|0); if (!($405)) { $406 = HEAP32[(828)>>2]|0; $407 = ($404>>>0)<($406>>>0); if ($407) { _abort(); // unreachable; } else { $408 = ((($R$1$i20)) + 20|0); HEAP32[$408>>2] = $404; $409 = ((($404)) + 24|0); HEAP32[$409>>2] = $R$1$i20; break; } } } } while(0); $410 = ($rsize$3$lcssa$i>>>0)<(16); L199: do { if ($410) { $411 = (($rsize$3$lcssa$i) + ($246))|0; $412 = $411 | 3; $413 = ((($v$3$lcssa$i)) + 4|0); HEAP32[$413>>2] = $412; $$sum18$i = (($411) + 4)|0; $414 = (($v$3$lcssa$i) + ($$sum18$i)|0); $415 = HEAP32[$414>>2]|0; $416 = $415 | 1; HEAP32[$414>>2] = $416; } else { $417 = $246 | 3; $418 = ((($v$3$lcssa$i)) + 4|0); HEAP32[$418>>2] = $417; $419 = $rsize$3$lcssa$i | 1; $$sum$i2334 = $246 | 4; $420 = (($v$3$lcssa$i) + ($$sum$i2334)|0); HEAP32[$420>>2] = $419; $$sum1$i24 = (($rsize$3$lcssa$i) + ($246))|0; $421 = (($v$3$lcssa$i) + ($$sum1$i24)|0); HEAP32[$421>>2] = $rsize$3$lcssa$i; $422 = $rsize$3$lcssa$i >>> 3; $423 = ($rsize$3$lcssa$i>>>0)<(256); if ($423) { $424 = $422 << 1; $425 = (852 + ($424<<2)|0); $426 = HEAP32[812>>2]|0; $427 = 1 << $422; $428 = $426 & $427; $429 = ($428|0)==(0); if ($429) { $430 = $426 | $427; HEAP32[812>>2] = $430; $$pre$i25 = (($424) + 2)|0; $$pre43$i = (852 + ($$pre$i25<<2)|0); $$pre$phi$i26Z2D = $$pre43$i;$F5$0$i = $425; } else { $$sum17$i = (($424) + 2)|0; $431 = (852 + ($$sum17$i<<2)|0); $432 = HEAP32[$431>>2]|0; $433 = HEAP32[(828)>>2]|0; $434 = ($432>>>0)<($433>>>0); if ($434) { _abort(); // unreachable; } else { $$pre$phi$i26Z2D = $431;$F5$0$i = $432; } } HEAP32[$$pre$phi$i26Z2D>>2] = $348; $435 = ((($F5$0$i)) + 12|0); HEAP32[$435>>2] = $348; $$sum15$i = (($246) + 8)|0; $436 = (($v$3$lcssa$i) + ($$sum15$i)|0); HEAP32[$436>>2] = $F5$0$i; $$sum16$i = (($246) + 12)|0; $437 = (($v$3$lcssa$i) + ($$sum16$i)|0); HEAP32[$437>>2] = $425; break; } $438 = $rsize$3$lcssa$i >>> 8; $439 = ($438|0)==(0); if ($439) { $I7$0$i = 0; } else { $440 = ($rsize$3$lcssa$i>>>0)>(16777215); if ($440) { $I7$0$i = 31; } else { $441 = (($438) + 1048320)|0; $442 = $441 >>> 16; $443 = $442 & 8; $444 = $438 << $443; $445 = (($444) + 520192)|0; $446 = $445 >>> 16; $447 = $446 & 4; $448 = $447 | $443; $449 = $444 << $447; $450 = (($449) + 245760)|0; $451 = $450 >>> 16; $452 = $451 & 2; $453 = $448 | $452; $454 = (14 - ($453))|0; $455 = $449 << $452; $456 = $455 >>> 15; $457 = (($454) + ($456))|0; $458 = $457 << 1; $459 = (($457) + 7)|0; $460 = $rsize$3$lcssa$i >>> $459; $461 = $460 & 1; $462 = $461 | $458; $I7$0$i = $462; } } $463 = (1116 + ($I7$0$i<<2)|0); $$sum2$i = (($246) + 28)|0; $464 = (($v$3$lcssa$i) + ($$sum2$i)|0); HEAP32[$464>>2] = $I7$0$i; $$sum3$i27 = (($246) + 16)|0; $465 = (($v$3$lcssa$i) + ($$sum3$i27)|0); $$sum4$i28 = (($246) + 20)|0; $466 = (($v$3$lcssa$i) + ($$sum4$i28)|0); HEAP32[$466>>2] = 0; HEAP32[$465>>2] = 0; $467 = HEAP32[(816)>>2]|0; $468 = 1 << $I7$0$i; $469 = $467 & $468; $470 = ($469|0)==(0); if ($470) { $471 = $467 | $468; HEAP32[(816)>>2] = $471; HEAP32[$463>>2] = $348; $$sum5$i = (($246) + 24)|0; $472 = (($v$3$lcssa$i) + ($$sum5$i)|0); HEAP32[$472>>2] = $463; $$sum6$i = (($246) + 12)|0; $473 = (($v$3$lcssa$i) + ($$sum6$i)|0); HEAP32[$473>>2] = $348; $$sum7$i = (($246) + 8)|0; $474 = (($v$3$lcssa$i) + ($$sum7$i)|0); HEAP32[$474>>2] = $348; break; } $475 = HEAP32[$463>>2]|0; $476 = ((($475)) + 4|0); $477 = HEAP32[$476>>2]|0; $478 = $477 & -8; $479 = ($478|0)==($rsize$3$lcssa$i|0); L217: do { if ($479) { $T$0$lcssa$i = $475; } else { $480 = ($I7$0$i|0)==(31); $481 = $I7$0$i >>> 1; $482 = (25 - ($481))|0; $483 = $480 ? 0 : $482; $484 = $rsize$3$lcssa$i << $483; $K12$029$i = $484;$T$028$i = $475; while(1) { $491 = $K12$029$i >>> 31; $492 = (((($T$028$i)) + 16|0) + ($491<<2)|0); $487 = HEAP32[$492>>2]|0; $493 = ($487|0)==(0|0); if ($493) { $$lcssa232 = $492;$T$028$i$lcssa = $T$028$i; break; } $485 = $K12$029$i << 1; $486 = ((($487)) + 4|0); $488 = HEAP32[$486>>2]|0; $489 = $488 & -8; $490 = ($489|0)==($rsize$3$lcssa$i|0); if ($490) { $T$0$lcssa$i = $487; break L217; } else { $K12$029$i = $485;$T$028$i = $487; } } $494 = HEAP32[(828)>>2]|0; $495 = ($$lcssa232>>>0)<($494>>>0); if ($495) { _abort(); // unreachable; } else { HEAP32[$$lcssa232>>2] = $348; $$sum11$i = (($246) + 24)|0; $496 = (($v$3$lcssa$i) + ($$sum11$i)|0); HEAP32[$496>>2] = $T$028$i$lcssa; $$sum12$i = (($246) + 12)|0; $497 = (($v$3$lcssa$i) + ($$sum12$i)|0); HEAP32[$497>>2] = $348; $$sum13$i = (($246) + 8)|0; $498 = (($v$3$lcssa$i) + ($$sum13$i)|0); HEAP32[$498>>2] = $348; break L199; } } } while(0); $499 = ((($T$0$lcssa$i)) + 8|0); $500 = HEAP32[$499>>2]|0; $501 = HEAP32[(828)>>2]|0; $502 = ($500>>>0)>=($501>>>0); $not$$i = ($T$0$lcssa$i>>>0)>=($501>>>0); $503 = $502 & $not$$i; if ($503) { $504 = ((($500)) + 12|0); HEAP32[$504>>2] = $348; HEAP32[$499>>2] = $348; $$sum8$i = (($246) + 8)|0; $505 = (($v$3$lcssa$i) + ($$sum8$i)|0); HEAP32[$505>>2] = $500; $$sum9$i = (($246) + 12)|0; $506 = (($v$3$lcssa$i) + ($$sum9$i)|0); HEAP32[$506>>2] = $T$0$lcssa$i; $$sum10$i = (($246) + 24)|0; $507 = (($v$3$lcssa$i) + ($$sum10$i)|0); HEAP32[$507>>2] = 0; break; } else { _abort(); // unreachable; } } } while(0); $508 = ((($v$3$lcssa$i)) + 8|0); $mem$0 = $508; return ($mem$0|0); } else { $nb$0 = $246; } } } } } } while(0); $509 = HEAP32[(820)>>2]|0; $510 = ($509>>>0)<($nb$0>>>0); if (!($510)) { $511 = (($509) - ($nb$0))|0; $512 = HEAP32[(832)>>2]|0; $513 = ($511>>>0)>(15); if ($513) { $514 = (($512) + ($nb$0)|0); HEAP32[(832)>>2] = $514; HEAP32[(820)>>2] = $511; $515 = $511 | 1; $$sum2 = (($nb$0) + 4)|0; $516 = (($512) + ($$sum2)|0); HEAP32[$516>>2] = $515; $517 = (($512) + ($509)|0); HEAP32[$517>>2] = $511; $518 = $nb$0 | 3; $519 = ((($512)) + 4|0); HEAP32[$519>>2] = $518; } else { HEAP32[(820)>>2] = 0; HEAP32[(832)>>2] = 0; $520 = $509 | 3; $521 = ((($512)) + 4|0); HEAP32[$521>>2] = $520; $$sum1 = (($509) + 4)|0; $522 = (($512) + ($$sum1)|0); $523 = HEAP32[$522>>2]|0; $524 = $523 | 1; HEAP32[$522>>2] = $524; } $525 = ((($512)) + 8|0); $mem$0 = $525; return ($mem$0|0); } $526 = HEAP32[(824)>>2]|0; $527 = ($526>>>0)>($nb$0>>>0); if ($527) { $528 = (($526) - ($nb$0))|0; HEAP32[(824)>>2] = $528; $529 = HEAP32[(836)>>2]|0; $530 = (($529) + ($nb$0)|0); HEAP32[(836)>>2] = $530; $531 = $528 | 1; $$sum = (($nb$0) + 4)|0; $532 = (($529) + ($$sum)|0); HEAP32[$532>>2] = $531; $533 = $nb$0 | 3; $534 = ((($529)) + 4|0); HEAP32[$534>>2] = $533; $535 = ((($529)) + 8|0); $mem$0 = $535; return ($mem$0|0); } $536 = HEAP32[1284>>2]|0; $537 = ($536|0)==(0); do { if ($537) { $538 = (_sysconf(30)|0); $539 = (($538) + -1)|0; $540 = $539 & $538; $541 = ($540|0)==(0); if ($541) { HEAP32[(1292)>>2] = $538; HEAP32[(1288)>>2] = $538; HEAP32[(1296)>>2] = -1; HEAP32[(1300)>>2] = -1; HEAP32[(1304)>>2] = 0; HEAP32[(1256)>>2] = 0; $542 = (_time((0|0))|0); $543 = $542 & -16; $544 = $543 ^ 1431655768; HEAP32[1284>>2] = $544; break; } else { _abort(); // unreachable; } } } while(0); $545 = (($nb$0) + 48)|0; $546 = HEAP32[(1292)>>2]|0; $547 = (($nb$0) + 47)|0; $548 = (($546) + ($547))|0; $549 = (0 - ($546))|0; $550 = $548 & $549; $551 = ($550>>>0)>($nb$0>>>0); if (!($551)) { $mem$0 = 0; return ($mem$0|0); } $552 = HEAP32[(1252)>>2]|0; $553 = ($552|0)==(0); if (!($553)) { $554 = HEAP32[(1244)>>2]|0; $555 = (($554) + ($550))|0; $556 = ($555>>>0)<=($554>>>0); $557 = ($555>>>0)>($552>>>0); $or$cond1$i = $556 | $557; if ($or$cond1$i) { $mem$0 = 0; return ($mem$0|0); } } $558 = HEAP32[(1256)>>2]|0; $559 = $558 & 4; $560 = ($559|0)==(0); L258: do { if ($560) { $561 = HEAP32[(836)>>2]|0; $562 = ($561|0)==(0|0); L260: do { if ($562) { label = 174; } else { $sp$0$i$i = (1260); while(1) { $563 = HEAP32[$sp$0$i$i>>2]|0; $564 = ($563>>>0)>($561>>>0); if (!($564)) { $565 = ((($sp$0$i$i)) + 4|0); $566 = HEAP32[$565>>2]|0; $567 = (($563) + ($566)|0); $568 = ($567>>>0)>($561>>>0); if ($568) { $$lcssa228 = $sp$0$i$i;$$lcssa230 = $565; break; } } $569 = ((($sp$0$i$i)) + 8|0); $570 = HEAP32[$569>>2]|0; $571 = ($570|0)==(0|0); if ($571) { label = 174; break L260; } else { $sp$0$i$i = $570; } } $594 = HEAP32[(824)>>2]|0; $595 = (($548) - ($594))|0; $596 = $595 & $549; $597 = ($596>>>0)<(2147483647); if ($597) { $598 = (_sbrk(($596|0))|0); $599 = HEAP32[$$lcssa228>>2]|0; $600 = HEAP32[$$lcssa230>>2]|0; $601 = (($599) + ($600)|0); $602 = ($598|0)==($601|0); $$3$i = $602 ? $596 : 0; if ($602) { $603 = ($598|0)==((-1)|0); if ($603) { $tsize$0323944$i = $$3$i; } else { $tbase$255$i = $598;$tsize$254$i = $$3$i; label = 194; break L258; } } else { $br$0$ph$i = $598;$ssize$1$ph$i = $596;$tsize$0$ph$i = $$3$i; label = 184; } } else { $tsize$0323944$i = 0; } } } while(0); do { if ((label|0) == 174) { $572 = (_sbrk(0)|0); $573 = ($572|0)==((-1)|0); if ($573) { $tsize$0323944$i = 0; } else { $574 = $572; $575 = HEAP32[(1288)>>2]|0; $576 = (($575) + -1)|0; $577 = $576 & $574; $578 = ($577|0)==(0); if ($578) { $ssize$0$i = $550; } else { $579 = (($576) + ($574))|0; $580 = (0 - ($575))|0; $581 = $579 & $580; $582 = (($550) - ($574))|0; $583 = (($582) + ($581))|0; $ssize$0$i = $583; } $584 = HEAP32[(1244)>>2]|0; $585 = (($584) + ($ssize$0$i))|0; $586 = ($ssize$0$i>>>0)>($nb$0>>>0); $587 = ($ssize$0$i>>>0)<(2147483647); $or$cond$i30 = $586 & $587; if ($or$cond$i30) { $588 = HEAP32[(1252)>>2]|0; $589 = ($588|0)==(0); if (!($589)) { $590 = ($585>>>0)<=($584>>>0); $591 = ($585>>>0)>($588>>>0); $or$cond2$i = $590 | $591; if ($or$cond2$i) { $tsize$0323944$i = 0; break; } } $592 = (_sbrk(($ssize$0$i|0))|0); $593 = ($592|0)==($572|0); $ssize$0$$i = $593 ? $ssize$0$i : 0; if ($593) { $tbase$255$i = $572;$tsize$254$i = $ssize$0$$i; label = 194; break L258; } else { $br$0$ph$i = $592;$ssize$1$ph$i = $ssize$0$i;$tsize$0$ph$i = $ssize$0$$i; label = 184; } } else { $tsize$0323944$i = 0; } } } } while(0); L280: do { if ((label|0) == 184) { $604 = (0 - ($ssize$1$ph$i))|0; $605 = ($br$0$ph$i|0)!=((-1)|0); $606 = ($ssize$1$ph$i>>>0)<(2147483647); $or$cond5$i = $606 & $605; $607 = ($545>>>0)>($ssize$1$ph$i>>>0); $or$cond6$i = $607 & $or$cond5$i; do { if ($or$cond6$i) { $608 = HEAP32[(1292)>>2]|0; $609 = (($547) - ($ssize$1$ph$i))|0; $610 = (($609) + ($608))|0; $611 = (0 - ($608))|0; $612 = $610 & $611; $613 = ($612>>>0)<(2147483647); if ($613) { $614 = (_sbrk(($612|0))|0); $615 = ($614|0)==((-1)|0); if ($615) { (_sbrk(($604|0))|0); $tsize$0323944$i = $tsize$0$ph$i; break L280; } else { $616 = (($612) + ($ssize$1$ph$i))|0; $ssize$2$i = $616; break; } } else { $ssize$2$i = $ssize$1$ph$i; } } else { $ssize$2$i = $ssize$1$ph$i; } } while(0); $617 = ($br$0$ph$i|0)==((-1)|0); if ($617) { $tsize$0323944$i = $tsize$0$ph$i; } else { $tbase$255$i = $br$0$ph$i;$tsize$254$i = $ssize$2$i; label = 194; break L258; } } } while(0); $618 = HEAP32[(1256)>>2]|0; $619 = $618 | 4; HEAP32[(1256)>>2] = $619; $tsize$1$i = $tsize$0323944$i; label = 191; } else { $tsize$1$i = 0; label = 191; } } while(0); if ((label|0) == 191) { $620 = ($550>>>0)<(2147483647); if ($620) { $621 = (_sbrk(($550|0))|0); $622 = (_sbrk(0)|0); $623 = ($621|0)!=((-1)|0); $624 = ($622|0)!=((-1)|0); $or$cond3$i = $623 & $624; $625 = ($621>>>0)<($622>>>0); $or$cond8$i = $625 & $or$cond3$i; if ($or$cond8$i) { $626 = $622; $627 = $621; $628 = (($626) - ($627))|0; $629 = (($nb$0) + 40)|0; $630 = ($628>>>0)>($629>>>0); $$tsize$1$i = $630 ? $628 : $tsize$1$i; if ($630) { $tbase$255$i = $621;$tsize$254$i = $$tsize$1$i; label = 194; } } } } if ((label|0) == 194) { $631 = HEAP32[(1244)>>2]|0; $632 = (($631) + ($tsize$254$i))|0; HEAP32[(1244)>>2] = $632; $633 = HEAP32[(1248)>>2]|0; $634 = ($632>>>0)>($633>>>0); if ($634) { HEAP32[(1248)>>2] = $632; } $635 = HEAP32[(836)>>2]|0; $636 = ($635|0)==(0|0); L299: do { if ($636) { $637 = HEAP32[(828)>>2]|0; $638 = ($637|0)==(0|0); $639 = ($tbase$255$i>>>0)<($637>>>0); $or$cond9$i = $638 | $639; if ($or$cond9$i) { HEAP32[(828)>>2] = $tbase$255$i; } HEAP32[(1260)>>2] = $tbase$255$i; HEAP32[(1264)>>2] = $tsize$254$i; HEAP32[(1272)>>2] = 0; $640 = HEAP32[1284>>2]|0; HEAP32[(848)>>2] = $640; HEAP32[(844)>>2] = -1; $i$02$i$i = 0; while(1) { $641 = $i$02$i$i << 1; $642 = (852 + ($641<<2)|0); $$sum$i$i = (($641) + 3)|0; $643 = (852 + ($$sum$i$i<<2)|0); HEAP32[$643>>2] = $642; $$sum1$i$i = (($641) + 2)|0; $644 = (852 + ($$sum1$i$i<<2)|0); HEAP32[$644>>2] = $642; $645 = (($i$02$i$i) + 1)|0; $exitcond$i$i = ($645|0)==(32); if ($exitcond$i$i) { break; } else { $i$02$i$i = $645; } } $646 = (($tsize$254$i) + -40)|0; $647 = ((($tbase$255$i)) + 8|0); $648 = $647; $649 = $648 & 7; $650 = ($649|0)==(0); $651 = (0 - ($648))|0; $652 = $651 & 7; $653 = $650 ? 0 : $652; $654 = (($tbase$255$i) + ($653)|0); $655 = (($646) - ($653))|0; HEAP32[(836)>>2] = $654; HEAP32[(824)>>2] = $655; $656 = $655 | 1; $$sum$i13$i = (($653) + 4)|0; $657 = (($tbase$255$i) + ($$sum$i13$i)|0); HEAP32[$657>>2] = $656; $$sum2$i$i = (($tsize$254$i) + -36)|0; $658 = (($tbase$255$i) + ($$sum2$i$i)|0); HEAP32[$658>>2] = 40; $659 = HEAP32[(1300)>>2]|0; HEAP32[(840)>>2] = $659; } else { $sp$084$i = (1260); while(1) { $660 = HEAP32[$sp$084$i>>2]|0; $661 = ((($sp$084$i)) + 4|0); $662 = HEAP32[$661>>2]|0; $663 = (($660) + ($662)|0); $664 = ($tbase$255$i|0)==($663|0); if ($664) { $$lcssa222 = $660;$$lcssa224 = $661;$$lcssa226 = $662;$sp$084$i$lcssa = $sp$084$i; label = 204; break; } $665 = ((($sp$084$i)) + 8|0); $666 = HEAP32[$665>>2]|0; $667 = ($666|0)==(0|0); if ($667) { break; } else { $sp$084$i = $666; } } if ((label|0) == 204) { $668 = ((($sp$084$i$lcssa)) + 12|0); $669 = HEAP32[$668>>2]|0; $670 = $669 & 8; $671 = ($670|0)==(0); if ($671) { $672 = ($635>>>0)>=($$lcssa222>>>0); $673 = ($635>>>0)<($tbase$255$i>>>0); $or$cond57$i = $673 & $672; if ($or$cond57$i) { $674 = (($$lcssa226) + ($tsize$254$i))|0; HEAP32[$$lcssa224>>2] = $674; $675 = HEAP32[(824)>>2]|0; $676 = (($675) + ($tsize$254$i))|0; $677 = ((($635)) + 8|0); $678 = $677; $679 = $678 & 7; $680 = ($679|0)==(0); $681 = (0 - ($678))|0; $682 = $681 & 7; $683 = $680 ? 0 : $682; $684 = (($635) + ($683)|0); $685 = (($676) - ($683))|0; HEAP32[(836)>>2] = $684; HEAP32[(824)>>2] = $685; $686 = $685 | 1; $$sum$i17$i = (($683) + 4)|0; $687 = (($635) + ($$sum$i17$i)|0); HEAP32[$687>>2] = $686; $$sum2$i18$i = (($676) + 4)|0; $688 = (($635) + ($$sum2$i18$i)|0); HEAP32[$688>>2] = 40; $689 = HEAP32[(1300)>>2]|0; HEAP32[(840)>>2] = $689; break; } } } $690 = HEAP32[(828)>>2]|0; $691 = ($tbase$255$i>>>0)<($690>>>0); if ($691) { HEAP32[(828)>>2] = $tbase$255$i; $755 = $tbase$255$i; } else { $755 = $690; } $692 = (($tbase$255$i) + ($tsize$254$i)|0); $sp$183$i = (1260); while(1) { $693 = HEAP32[$sp$183$i>>2]|0; $694 = ($693|0)==($692|0); if ($694) { $$lcssa219 = $sp$183$i;$sp$183$i$lcssa = $sp$183$i; label = 212; break; } $695 = ((($sp$183$i)) + 8|0); $696 = HEAP32[$695>>2]|0; $697 = ($696|0)==(0|0); if ($697) { $sp$0$i$i$i = (1260); break; } else { $sp$183$i = $696; } } if ((label|0) == 212) { $698 = ((($sp$183$i$lcssa)) + 12|0); $699 = HEAP32[$698>>2]|0; $700 = $699 & 8; $701 = ($700|0)==(0); if ($701) { HEAP32[$$lcssa219>>2] = $tbase$255$i; $702 = ((($sp$183$i$lcssa)) + 4|0); $703 = HEAP32[$702>>2]|0; $704 = (($703) + ($tsize$254$i))|0; HEAP32[$702>>2] = $704; $705 = ((($tbase$255$i)) + 8|0); $706 = $705; $707 = $706 & 7; $708 = ($707|0)==(0); $709 = (0 - ($706))|0; $710 = $709 & 7; $711 = $708 ? 0 : $710; $712 = (($tbase$255$i) + ($711)|0); $$sum112$i = (($tsize$254$i) + 8)|0; $713 = (($tbase$255$i) + ($$sum112$i)|0); $714 = $713; $715 = $714 & 7; $716 = ($715|0)==(0); $717 = (0 - ($714))|0; $718 = $717 & 7; $719 = $716 ? 0 : $718; $$sum113$i = (($719) + ($tsize$254$i))|0; $720 = (($tbase$255$i) + ($$sum113$i)|0); $721 = $720; $722 = $712; $723 = (($721) - ($722))|0; $$sum$i19$i = (($711) + ($nb$0))|0; $724 = (($tbase$255$i) + ($$sum$i19$i)|0); $725 = (($723) - ($nb$0))|0; $726 = $nb$0 | 3; $$sum1$i20$i = (($711) + 4)|0; $727 = (($tbase$255$i) + ($$sum1$i20$i)|0); HEAP32[$727>>2] = $726; $728 = ($720|0)==($635|0); L324: do { if ($728) { $729 = HEAP32[(824)>>2]|0; $730 = (($729) + ($725))|0; HEAP32[(824)>>2] = $730; HEAP32[(836)>>2] = $724; $731 = $730 | 1; $$sum42$i$i = (($$sum$i19$i) + 4)|0; $732 = (($tbase$255$i) + ($$sum42$i$i)|0); HEAP32[$732>>2] = $731; } else { $733 = HEAP32[(832)>>2]|0; $734 = ($720|0)==($733|0); if ($734) { $735 = HEAP32[(820)>>2]|0; $736 = (($735) + ($725))|0; HEAP32[(820)>>2] = $736; HEAP32[(832)>>2] = $724; $737 = $736 | 1; $$sum40$i$i = (($$sum$i19$i) + 4)|0; $738 = (($tbase$255$i) + ($$sum40$i$i)|0); HEAP32[$738>>2] = $737; $$sum41$i$i = (($736) + ($$sum$i19$i))|0; $739 = (($tbase$255$i) + ($$sum41$i$i)|0); HEAP32[$739>>2] = $736; break; } $$sum2$i21$i = (($tsize$254$i) + 4)|0; $$sum114$i = (($$sum2$i21$i) + ($719))|0; $740 = (($tbase$255$i) + ($$sum114$i)|0); $741 = HEAP32[$740>>2]|0; $742 = $741 & 3; $743 = ($742|0)==(1); if ($743) { $744 = $741 & -8; $745 = $741 >>> 3; $746 = ($741>>>0)<(256); L332: do { if ($746) { $$sum3738$i$i = $719 | 8; $$sum124$i = (($$sum3738$i$i) + ($tsize$254$i))|0; $747 = (($tbase$255$i) + ($$sum124$i)|0); $748 = HEAP32[$747>>2]|0; $$sum39$i$i = (($tsize$254$i) + 12)|0; $$sum125$i = (($$sum39$i$i) + ($719))|0; $749 = (($tbase$255$i) + ($$sum125$i)|0); $750 = HEAP32[$749>>2]|0; $751 = $745 << 1; $752 = (852 + ($751<<2)|0); $753 = ($748|0)==($752|0); do { if (!($753)) { $754 = ($748>>>0)<($755>>>0); if ($754) { _abort(); // unreachable; } $756 = ((($748)) + 12|0); $757 = HEAP32[$756>>2]|0; $758 = ($757|0)==($720|0); if ($758) { break; } _abort(); // unreachable; } } while(0); $759 = ($750|0)==($748|0); if ($759) { $760 = 1 << $745; $761 = $760 ^ -1; $762 = HEAP32[812>>2]|0; $763 = $762 & $761; HEAP32[812>>2] = $763; break; } $764 = ($750|0)==($752|0); do { if ($764) { $$pre57$i$i = ((($750)) + 8|0); $$pre$phi58$i$iZ2D = $$pre57$i$i; } else { $765 = ($750>>>0)<($755>>>0); if ($765) { _abort(); // unreachable; } $766 = ((($750)) + 8|0); $767 = HEAP32[$766>>2]|0; $768 = ($767|0)==($720|0); if ($768) { $$pre$phi58$i$iZ2D = $766; break; } _abort(); // unreachable; } } while(0); $769 = ((($748)) + 12|0); HEAP32[$769>>2] = $750; HEAP32[$$pre$phi58$i$iZ2D>>2] = $748; } else { $$sum34$i$i = $719 | 24; $$sum115$i = (($$sum34$i$i) + ($tsize$254$i))|0; $770 = (($tbase$255$i) + ($$sum115$i)|0); $771 = HEAP32[$770>>2]|0; $$sum5$i$i = (($tsize$254$i) + 12)|0; $$sum116$i = (($$sum5$i$i) + ($719))|0; $772 = (($tbase$255$i) + ($$sum116$i)|0); $773 = HEAP32[$772>>2]|0; $774 = ($773|0)==($720|0); do { if ($774) { $$sum67$i$i = $719 | 16; $$sum122$i = (($$sum2$i21$i) + ($$sum67$i$i))|0; $784 = (($tbase$255$i) + ($$sum122$i)|0); $785 = HEAP32[$784>>2]|0; $786 = ($785|0)==(0|0); if ($786) { $$sum123$i = (($$sum67$i$i) + ($tsize$254$i))|0; $787 = (($tbase$255$i) + ($$sum123$i)|0); $788 = HEAP32[$787>>2]|0; $789 = ($788|0)==(0|0); if ($789) { $R$1$i$i = 0; break; } else { $R$0$i$i = $788;$RP$0$i$i = $787; } } else { $R$0$i$i = $785;$RP$0$i$i = $784; } while(1) { $790 = ((($R$0$i$i)) + 20|0); $791 = HEAP32[$790>>2]|0; $792 = ($791|0)==(0|0); if (!($792)) { $R$0$i$i = $791;$RP$0$i$i = $790; continue; } $793 = ((($R$0$i$i)) + 16|0); $794 = HEAP32[$793>>2]|0; $795 = ($794|0)==(0|0); if ($795) { $R$0$i$i$lcssa = $R$0$i$i;$RP$0$i$i$lcssa = $RP$0$i$i; break; } else { $R$0$i$i = $794;$RP$0$i$i = $793; } } $796 = ($RP$0$i$i$lcssa>>>0)<($755>>>0); if ($796) { _abort(); // unreachable; } else { HEAP32[$RP$0$i$i$lcssa>>2] = 0; $R$1$i$i = $R$0$i$i$lcssa; break; } } else { $$sum3536$i$i = $719 | 8; $$sum117$i = (($$sum3536$i$i) + ($tsize$254$i))|0; $775 = (($tbase$255$i) + ($$sum117$i)|0); $776 = HEAP32[$775>>2]|0; $777 = ($776>>>0)<($755>>>0); if ($777) { _abort(); // unreachable; } $778 = ((($776)) + 12|0); $779 = HEAP32[$778>>2]|0; $780 = ($779|0)==($720|0); if (!($780)) { _abort(); // unreachable; } $781 = ((($773)) + 8|0); $782 = HEAP32[$781>>2]|0; $783 = ($782|0)==($720|0); if ($783) { HEAP32[$778>>2] = $773; HEAP32[$781>>2] = $776; $R$1$i$i = $773; break; } else { _abort(); // unreachable; } } } while(0); $797 = ($771|0)==(0|0); if ($797) { break; } $$sum30$i$i = (($tsize$254$i) + 28)|0; $$sum118$i = (($$sum30$i$i) + ($719))|0; $798 = (($tbase$255$i) + ($$sum118$i)|0); $799 = HEAP32[$798>>2]|0; $800 = (1116 + ($799<<2)|0); $801 = HEAP32[$800>>2]|0; $802 = ($720|0)==($801|0); do { if ($802) { HEAP32[$800>>2] = $R$1$i$i; $cond$i$i = ($R$1$i$i|0)==(0|0); if (!($cond$i$i)) { break; } $803 = 1 << $799; $804 = $803 ^ -1; $805 = HEAP32[(816)>>2]|0; $806 = $805 & $804; HEAP32[(816)>>2] = $806; break L332; } else { $807 = HEAP32[(828)>>2]|0; $808 = ($771>>>0)<($807>>>0); if ($808) { _abort(); // unreachable; } $809 = ((($771)) + 16|0); $810 = HEAP32[$809>>2]|0; $811 = ($810|0)==($720|0); if ($811) { HEAP32[$809>>2] = $R$1$i$i; } else { $812 = ((($771)) + 20|0); HEAP32[$812>>2] = $R$1$i$i; } $813 = ($R$1$i$i|0)==(0|0); if ($813) { break L332; } } } while(0); $814 = HEAP32[(828)>>2]|0; $815 = ($R$1$i$i>>>0)<($814>>>0); if ($815) { _abort(); // unreachable; } $816 = ((($R$1$i$i)) + 24|0); HEAP32[$816>>2] = $771; $$sum3132$i$i = $719 | 16; $$sum119$i = (($$sum3132$i$i) + ($tsize$254$i))|0; $817 = (($tbase$255$i) + ($$sum119$i)|0); $818 = HEAP32[$817>>2]|0; $819 = ($818|0)==(0|0); do { if (!($819)) { $820 = ($818>>>0)<($814>>>0); if ($820) { _abort(); // unreachable; } else { $821 = ((($R$1$i$i)) + 16|0); HEAP32[$821>>2] = $818; $822 = ((($818)) + 24|0); HEAP32[$822>>2] = $R$1$i$i; break; } } } while(0); $$sum120$i = (($$sum2$i21$i) + ($$sum3132$i$i))|0; $823 = (($tbase$255$i) + ($$sum120$i)|0); $824 = HEAP32[$823>>2]|0; $825 = ($824|0)==(0|0); if ($825) { break; } $826 = HEAP32[(828)>>2]|0; $827 = ($824>>>0)<($826>>>0); if ($827) { _abort(); // unreachable; } else { $828 = ((($R$1$i$i)) + 20|0); HEAP32[$828>>2] = $824; $829 = ((($824)) + 24|0); HEAP32[$829>>2] = $R$1$i$i; break; } } } while(0); $$sum9$i$i = $744 | $719; $$sum121$i = (($$sum9$i$i) + ($tsize$254$i))|0; $830 = (($tbase$255$i) + ($$sum121$i)|0); $831 = (($744) + ($725))|0; $oldfirst$0$i$i = $830;$qsize$0$i$i = $831; } else { $oldfirst$0$i$i = $720;$qsize$0$i$i = $725; } $832 = ((($oldfirst$0$i$i)) + 4|0); $833 = HEAP32[$832>>2]|0; $834 = $833 & -2; HEAP32[$832>>2] = $834; $835 = $qsize$0$i$i | 1; $$sum10$i$i = (($$sum$i19$i) + 4)|0; $836 = (($tbase$255$i) + ($$sum10$i$i)|0); HEAP32[$836>>2] = $835; $$sum11$i$i = (($qsize$0$i$i) + ($$sum$i19$i))|0; $837 = (($tbase$255$i) + ($$sum11$i$i)|0); HEAP32[$837>>2] = $qsize$0$i$i; $838 = $qsize$0$i$i >>> 3; $839 = ($qsize$0$i$i>>>0)<(256); if ($839) { $840 = $838 << 1; $841 = (852 + ($840<<2)|0); $842 = HEAP32[812>>2]|0; $843 = 1 << $838; $844 = $842 & $843; $845 = ($844|0)==(0); do { if ($845) { $846 = $842 | $843; HEAP32[812>>2] = $846; $$pre$i22$i = (($840) + 2)|0; $$pre56$i$i = (852 + ($$pre$i22$i<<2)|0); $$pre$phi$i23$iZ2D = $$pre56$i$i;$F4$0$i$i = $841; } else { $$sum29$i$i = (($840) + 2)|0; $847 = (852 + ($$sum29$i$i<<2)|0); $848 = HEAP32[$847>>2]|0; $849 = HEAP32[(828)>>2]|0; $850 = ($848>>>0)<($849>>>0); if (!($850)) { $$pre$phi$i23$iZ2D = $847;$F4$0$i$i = $848; break; } _abort(); // unreachable; } } while(0); HEAP32[$$pre$phi$i23$iZ2D>>2] = $724; $851 = ((($F4$0$i$i)) + 12|0); HEAP32[$851>>2] = $724; $$sum27$i$i = (($$sum$i19$i) + 8)|0; $852 = (($tbase$255$i) + ($$sum27$i$i)|0); HEAP32[$852>>2] = $F4$0$i$i; $$sum28$i$i = (($$sum$i19$i) + 12)|0; $853 = (($tbase$255$i) + ($$sum28$i$i)|0); HEAP32[$853>>2] = $841; break; } $854 = $qsize$0$i$i >>> 8; $855 = ($854|0)==(0); do { if ($855) { $I7$0$i$i = 0; } else { $856 = ($qsize$0$i$i>>>0)>(16777215); if ($856) { $I7$0$i$i = 31; break; } $857 = (($854) + 1048320)|0; $858 = $857 >>> 16; $859 = $858 & 8; $860 = $854 << $859; $861 = (($860) + 520192)|0; $862 = $861 >>> 16; $863 = $862 & 4; $864 = $863 | $859; $865 = $860 << $863; $866 = (($865) + 245760)|0; $867 = $866 >>> 16; $868 = $867 & 2; $869 = $864 | $868; $870 = (14 - ($869))|0; $871 = $865 << $868; $872 = $871 >>> 15; $873 = (($870) + ($872))|0; $874 = $873 << 1; $875 = (($873) + 7)|0; $876 = $qsize$0$i$i >>> $875; $877 = $876 & 1; $878 = $877 | $874; $I7$0$i$i = $878; } } while(0); $879 = (1116 + ($I7$0$i$i<<2)|0); $$sum12$i$i = (($$sum$i19$i) + 28)|0; $880 = (($tbase$255$i) + ($$sum12$i$i)|0); HEAP32[$880>>2] = $I7$0$i$i; $$sum13$i$i = (($$sum$i19$i) + 16)|0; $881 = (($tbase$255$i) + ($$sum13$i$i)|0); $$sum14$i$i = (($$sum$i19$i) + 20)|0; $882 = (($tbase$255$i) + ($$sum14$i$i)|0); HEAP32[$882>>2] = 0; HEAP32[$881>>2] = 0; $883 = HEAP32[(816)>>2]|0; $884 = 1 << $I7$0$i$i; $885 = $883 & $884; $886 = ($885|0)==(0); if ($886) { $887 = $883 | $884; HEAP32[(816)>>2] = $887; HEAP32[$879>>2] = $724; $$sum15$i$i = (($$sum$i19$i) + 24)|0; $888 = (($tbase$255$i) + ($$sum15$i$i)|0); HEAP32[$888>>2] = $879; $$sum16$i$i = (($$sum$i19$i) + 12)|0; $889 = (($tbase$255$i) + ($$sum16$i$i)|0); HEAP32[$889>>2] = $724; $$sum17$i$i = (($$sum$i19$i) + 8)|0; $890 = (($tbase$255$i) + ($$sum17$i$i)|0); HEAP32[$890>>2] = $724; break; } $891 = HEAP32[$879>>2]|0; $892 = ((($891)) + 4|0); $893 = HEAP32[$892>>2]|0; $894 = $893 & -8; $895 = ($894|0)==($qsize$0$i$i|0); L418: do { if ($895) { $T$0$lcssa$i25$i = $891; } else { $896 = ($I7$0$i$i|0)==(31); $897 = $I7$0$i$i >>> 1; $898 = (25 - ($897))|0; $899 = $896 ? 0 : $898; $900 = $qsize$0$i$i << $899; $K8$051$i$i = $900;$T$050$i$i = $891; while(1) { $907 = $K8$051$i$i >>> 31; $908 = (((($T$050$i$i)) + 16|0) + ($907<<2)|0); $903 = HEAP32[$908>>2]|0; $909 = ($903|0)==(0|0); if ($909) { $$lcssa = $908;$T$050$i$i$lcssa = $T$050$i$i; break; } $901 = $K8$051$i$i << 1; $902 = ((($903)) + 4|0); $904 = HEAP32[$902>>2]|0; $905 = $904 & -8; $906 = ($905|0)==($qsize$0$i$i|0); if ($906) { $T$0$lcssa$i25$i = $903; break L418; } else { $K8$051$i$i = $901;$T$050$i$i = $903; } } $910 = HEAP32[(828)>>2]|0; $911 = ($$lcssa>>>0)<($910>>>0); if ($911) { _abort(); // unreachable; } else { HEAP32[$$lcssa>>2] = $724; $$sum23$i$i = (($$sum$i19$i) + 24)|0; $912 = (($tbase$255$i) + ($$sum23$i$i)|0); HEAP32[$912>>2] = $T$050$i$i$lcssa; $$sum24$i$i = (($$sum$i19$i) + 12)|0; $913 = (($tbase$255$i) + ($$sum24$i$i)|0); HEAP32[$913>>2] = $724; $$sum25$i$i = (($$sum$i19$i) + 8)|0; $914 = (($tbase$255$i) + ($$sum25$i$i)|0); HEAP32[$914>>2] = $724; break L324; } } } while(0); $915 = ((($T$0$lcssa$i25$i)) + 8|0); $916 = HEAP32[$915>>2]|0; $917 = HEAP32[(828)>>2]|0; $918 = ($916>>>0)>=($917>>>0); $not$$i26$i = ($T$0$lcssa$i25$i>>>0)>=($917>>>0); $919 = $918 & $not$$i26$i; if ($919) { $920 = ((($916)) + 12|0); HEAP32[$920>>2] = $724; HEAP32[$915>>2] = $724; $$sum20$i$i = (($$sum$i19$i) + 8)|0; $921 = (($tbase$255$i) + ($$sum20$i$i)|0); HEAP32[$921>>2] = $916; $$sum21$i$i = (($$sum$i19$i) + 12)|0; $922 = (($tbase$255$i) + ($$sum21$i$i)|0); HEAP32[$922>>2] = $T$0$lcssa$i25$i; $$sum22$i$i = (($$sum$i19$i) + 24)|0; $923 = (($tbase$255$i) + ($$sum22$i$i)|0); HEAP32[$923>>2] = 0; break; } else { _abort(); // unreachable; } } } while(0); $$sum1819$i$i = $711 | 8; $924 = (($tbase$255$i) + ($$sum1819$i$i)|0); $mem$0 = $924; return ($mem$0|0); } else { $sp$0$i$i$i = (1260); } } while(1) { $925 = HEAP32[$sp$0$i$i$i>>2]|0; $926 = ($925>>>0)>($635>>>0); if (!($926)) { $927 = ((($sp$0$i$i$i)) + 4|0); $928 = HEAP32[$927>>2]|0; $929 = (($925) + ($928)|0); $930 = ($929>>>0)>($635>>>0); if ($930) { $$lcssa215 = $925;$$lcssa216 = $928;$$lcssa217 = $929; break; } } $931 = ((($sp$0$i$i$i)) + 8|0); $932 = HEAP32[$931>>2]|0; $sp$0$i$i$i = $932; } $$sum$i14$i = (($$lcssa216) + -47)|0; $$sum1$i15$i = (($$lcssa216) + -39)|0; $933 = (($$lcssa215) + ($$sum1$i15$i)|0); $934 = $933; $935 = $934 & 7; $936 = ($935|0)==(0); $937 = (0 - ($934))|0; $938 = $937 & 7; $939 = $936 ? 0 : $938; $$sum2$i16$i = (($$sum$i14$i) + ($939))|0; $940 = (($$lcssa215) + ($$sum2$i16$i)|0); $941 = ((($635)) + 16|0); $942 = ($940>>>0)<($941>>>0); $943 = $942 ? $635 : $940; $944 = ((($943)) + 8|0); $945 = (($tsize$254$i) + -40)|0; $946 = ((($tbase$255$i)) + 8|0); $947 = $946; $948 = $947 & 7; $949 = ($948|0)==(0); $950 = (0 - ($947))|0; $951 = $950 & 7; $952 = $949 ? 0 : $951; $953 = (($tbase$255$i) + ($952)|0); $954 = (($945) - ($952))|0; HEAP32[(836)>>2] = $953; HEAP32[(824)>>2] = $954; $955 = $954 | 1; $$sum$i$i$i = (($952) + 4)|0; $956 = (($tbase$255$i) + ($$sum$i$i$i)|0); HEAP32[$956>>2] = $955; $$sum2$i$i$i = (($tsize$254$i) + -36)|0; $957 = (($tbase$255$i) + ($$sum2$i$i$i)|0); HEAP32[$957>>2] = 40; $958 = HEAP32[(1300)>>2]|0; HEAP32[(840)>>2] = $958; $959 = ((($943)) + 4|0); HEAP32[$959>>2] = 27; ;HEAP32[$944>>2]=HEAP32[(1260)>>2]|0;HEAP32[$944+4>>2]=HEAP32[(1260)+4>>2]|0;HEAP32[$944+8>>2]=HEAP32[(1260)+8>>2]|0;HEAP32[$944+12>>2]=HEAP32[(1260)+12>>2]|0; HEAP32[(1260)>>2] = $tbase$255$i; HEAP32[(1264)>>2] = $tsize$254$i; HEAP32[(1272)>>2] = 0; HEAP32[(1268)>>2] = $944; $960 = ((($943)) + 28|0); HEAP32[$960>>2] = 7; $961 = ((($943)) + 32|0); $962 = ($961>>>0)<($$lcssa217>>>0); if ($962) { $964 = $960; while(1) { $963 = ((($964)) + 4|0); HEAP32[$963>>2] = 7; $965 = ((($964)) + 8|0); $966 = ($965>>>0)<($$lcssa217>>>0); if ($966) { $964 = $963; } else { break; } } } $967 = ($943|0)==($635|0); if (!($967)) { $968 = $943; $969 = $635; $970 = (($968) - ($969))|0; $971 = HEAP32[$959>>2]|0; $972 = $971 & -2; HEAP32[$959>>2] = $972; $973 = $970 | 1; $974 = ((($635)) + 4|0); HEAP32[$974>>2] = $973; HEAP32[$943>>2] = $970; $975 = $970 >>> 3; $976 = ($970>>>0)<(256); if ($976) { $977 = $975 << 1; $978 = (852 + ($977<<2)|0); $979 = HEAP32[812>>2]|0; $980 = 1 << $975; $981 = $979 & $980; $982 = ($981|0)==(0); if ($982) { $983 = $979 | $980; HEAP32[812>>2] = $983; $$pre$i$i = (($977) + 2)|0; $$pre14$i$i = (852 + ($$pre$i$i<<2)|0); $$pre$phi$i$iZ2D = $$pre14$i$i;$F$0$i$i = $978; } else { $$sum4$i$i = (($977) + 2)|0; $984 = (852 + ($$sum4$i$i<<2)|0); $985 = HEAP32[$984>>2]|0; $986 = HEAP32[(828)>>2]|0; $987 = ($985>>>0)<($986>>>0); if ($987) { _abort(); // unreachable; } else { $$pre$phi$i$iZ2D = $984;$F$0$i$i = $985; } } HEAP32[$$pre$phi$i$iZ2D>>2] = $635; $988 = ((($F$0$i$i)) + 12|0); HEAP32[$988>>2] = $635; $989 = ((($635)) + 8|0); HEAP32[$989>>2] = $F$0$i$i; $990 = ((($635)) + 12|0); HEAP32[$990>>2] = $978; break; } $991 = $970 >>> 8; $992 = ($991|0)==(0); if ($992) { $I1$0$i$i = 0; } else { $993 = ($970>>>0)>(16777215); if ($993) { $I1$0$i$i = 31; } else { $994 = (($991) + 1048320)|0; $995 = $994 >>> 16; $996 = $995 & 8; $997 = $991 << $996; $998 = (($997) + 520192)|0; $999 = $998 >>> 16; $1000 = $999 & 4; $1001 = $1000 | $996; $1002 = $997 << $1000; $1003 = (($1002) + 245760)|0; $1004 = $1003 >>> 16; $1005 = $1004 & 2; $1006 = $1001 | $1005; $1007 = (14 - ($1006))|0; $1008 = $1002 << $1005; $1009 = $1008 >>> 15; $1010 = (($1007) + ($1009))|0; $1011 = $1010 << 1; $1012 = (($1010) + 7)|0; $1013 = $970 >>> $1012; $1014 = $1013 & 1; $1015 = $1014 | $1011; $I1$0$i$i = $1015; } } $1016 = (1116 + ($I1$0$i$i<<2)|0); $1017 = ((($635)) + 28|0); HEAP32[$1017>>2] = $I1$0$i$i; $1018 = ((($635)) + 20|0); HEAP32[$1018>>2] = 0; HEAP32[$941>>2] = 0; $1019 = HEAP32[(816)>>2]|0; $1020 = 1 << $I1$0$i$i; $1021 = $1019 & $1020; $1022 = ($1021|0)==(0); if ($1022) { $1023 = $1019 | $1020; HEAP32[(816)>>2] = $1023; HEAP32[$1016>>2] = $635; $1024 = ((($635)) + 24|0); HEAP32[$1024>>2] = $1016; $1025 = ((($635)) + 12|0); HEAP32[$1025>>2] = $635; $1026 = ((($635)) + 8|0); HEAP32[$1026>>2] = $635; break; } $1027 = HEAP32[$1016>>2]|0; $1028 = ((($1027)) + 4|0); $1029 = HEAP32[$1028>>2]|0; $1030 = $1029 & -8; $1031 = ($1030|0)==($970|0); L459: do { if ($1031) { $T$0$lcssa$i$i = $1027; } else { $1032 = ($I1$0$i$i|0)==(31); $1033 = $I1$0$i$i >>> 1; $1034 = (25 - ($1033))|0; $1035 = $1032 ? 0 : $1034; $1036 = $970 << $1035; $K2$07$i$i = $1036;$T$06$i$i = $1027; while(1) { $1043 = $K2$07$i$i >>> 31; $1044 = (((($T$06$i$i)) + 16|0) + ($1043<<2)|0); $1039 = HEAP32[$1044>>2]|0; $1045 = ($1039|0)==(0|0); if ($1045) { $$lcssa211 = $1044;$T$06$i$i$lcssa = $T$06$i$i; break; } $1037 = $K2$07$i$i << 1; $1038 = ((($1039)) + 4|0); $1040 = HEAP32[$1038>>2]|0; $1041 = $1040 & -8; $1042 = ($1041|0)==($970|0); if ($1042) { $T$0$lcssa$i$i = $1039; break L459; } else { $K2$07$i$i = $1037;$T$06$i$i = $1039; } } $1046 = HEAP32[(828)>>2]|0; $1047 = ($$lcssa211>>>0)<($1046>>>0); if ($1047) { _abort(); // unreachable; } else { HEAP32[$$lcssa211>>2] = $635; $1048 = ((($635)) + 24|0); HEAP32[$1048>>2] = $T$06$i$i$lcssa; $1049 = ((($635)) + 12|0); HEAP32[$1049>>2] = $635; $1050 = ((($635)) + 8|0); HEAP32[$1050>>2] = $635; break L299; } } } while(0); $1051 = ((($T$0$lcssa$i$i)) + 8|0); $1052 = HEAP32[$1051>>2]|0; $1053 = HEAP32[(828)>>2]|0; $1054 = ($1052>>>0)>=($1053>>>0); $not$$i$i = ($T$0$lcssa$i$i>>>0)>=($1053>>>0); $1055 = $1054 & $not$$i$i; if ($1055) { $1056 = ((($1052)) + 12|0); HEAP32[$1056>>2] = $635; HEAP32[$1051>>2] = $635; $1057 = ((($635)) + 8|0); HEAP32[$1057>>2] = $1052; $1058 = ((($635)) + 12|0); HEAP32[$1058>>2] = $T$0$lcssa$i$i; $1059 = ((($635)) + 24|0); HEAP32[$1059>>2] = 0; break; } else { _abort(); // unreachable; } } } } while(0); $1060 = HEAP32[(824)>>2]|0; $1061 = ($1060>>>0)>($nb$0>>>0); if ($1061) { $1062 = (($1060) - ($nb$0))|0; HEAP32[(824)>>2] = $1062; $1063 = HEAP32[(836)>>2]|0; $1064 = (($1063) + ($nb$0)|0); HEAP32[(836)>>2] = $1064; $1065 = $1062 | 1; $$sum$i32 = (($nb$0) + 4)|0; $1066 = (($1063) + ($$sum$i32)|0); HEAP32[$1066>>2] = $1065; $1067 = $nb$0 | 3; $1068 = ((($1063)) + 4|0); HEAP32[$1068>>2] = $1067; $1069 = ((($1063)) + 8|0); $mem$0 = $1069; return ($mem$0|0); } } $1070 = (___errno_location()|0); HEAP32[$1070>>2] = 12; $mem$0 = 0; return ($mem$0|0); } function _free($mem) { $mem = $mem|0; var $$lcssa = 0, $$pre = 0, $$pre$phi59Z2D = 0, $$pre$phi61Z2D = 0, $$pre$phiZ2D = 0, $$pre57 = 0, $$pre58 = 0, $$pre60 = 0, $$sum = 0, $$sum11 = 0, $$sum12 = 0, $$sum13 = 0, $$sum14 = 0, $$sum1718 = 0, $$sum19 = 0, $$sum2 = 0, $$sum20 = 0, $$sum22 = 0, $$sum23 = 0, $$sum24 = 0; var $$sum25 = 0, $$sum26 = 0, $$sum27 = 0, $$sum28 = 0, $$sum29 = 0, $$sum3 = 0, $$sum30 = 0, $$sum31 = 0, $$sum5 = 0, $$sum67 = 0, $$sum8 = 0, $$sum9 = 0, $0 = 0, $1 = 0, $10 = 0, $100 = 0, $101 = 0, $102 = 0, $103 = 0, $104 = 0; var $105 = 0, $106 = 0, $107 = 0, $108 = 0, $109 = 0, $11 = 0, $110 = 0, $111 = 0, $112 = 0, $113 = 0, $114 = 0, $115 = 0, $116 = 0, $117 = 0, $118 = 0, $119 = 0, $12 = 0, $120 = 0, $121 = 0, $122 = 0; var $123 = 0, $124 = 0, $125 = 0, $126 = 0, $127 = 0, $128 = 0, $129 = 0, $13 = 0, $130 = 0, $131 = 0, $132 = 0, $133 = 0, $134 = 0, $135 = 0, $136 = 0, $137 = 0, $138 = 0, $139 = 0, $14 = 0, $140 = 0; var $141 = 0, $142 = 0, $143 = 0, $144 = 0, $145 = 0, $146 = 0, $147 = 0, $148 = 0, $149 = 0, $15 = 0, $150 = 0, $151 = 0, $152 = 0, $153 = 0, $154 = 0, $155 = 0, $156 = 0, $157 = 0, $158 = 0, $159 = 0; var $16 = 0, $160 = 0, $161 = 0, $162 = 0, $163 = 0, $164 = 0, $165 = 0, $166 = 0, $167 = 0, $168 = 0, $169 = 0, $17 = 0, $170 = 0, $171 = 0, $172 = 0, $173 = 0, $174 = 0, $175 = 0, $176 = 0, $177 = 0; var $178 = 0, $179 = 0, $18 = 0, $180 = 0, $181 = 0, $182 = 0, $183 = 0, $184 = 0, $185 = 0, $186 = 0, $187 = 0, $188 = 0, $189 = 0, $19 = 0, $190 = 0, $191 = 0, $192 = 0, $193 = 0, $194 = 0, $195 = 0; var $196 = 0, $197 = 0, $198 = 0, $199 = 0, $2 = 0, $20 = 0, $200 = 0, $201 = 0, $202 = 0, $203 = 0, $204 = 0, $205 = 0, $206 = 0, $207 = 0, $208 = 0, $209 = 0, $21 = 0, $210 = 0, $211 = 0, $212 = 0; var $213 = 0, $214 = 0, $215 = 0, $216 = 0, $217 = 0, $218 = 0, $219 = 0, $22 = 0, $220 = 0, $221 = 0, $222 = 0, $223 = 0, $224 = 0, $225 = 0, $226 = 0, $227 = 0, $228 = 0, $229 = 0, $23 = 0, $230 = 0; var $231 = 0, $232 = 0, $233 = 0, $234 = 0, $235 = 0, $236 = 0, $237 = 0, $238 = 0, $239 = 0, $24 = 0, $240 = 0, $241 = 0, $242 = 0, $243 = 0, $244 = 0, $245 = 0, $246 = 0, $247 = 0, $248 = 0, $249 = 0; var $25 = 0, $250 = 0, $251 = 0, $252 = 0, $253 = 0, $254 = 0, $255 = 0, $256 = 0, $257 = 0, $258 = 0, $259 = 0, $26 = 0, $260 = 0, $261 = 0, $262 = 0, $263 = 0, $264 = 0, $265 = 0, $266 = 0, $267 = 0; var $268 = 0, $269 = 0, $27 = 0, $270 = 0, $271 = 0, $272 = 0, $273 = 0, $274 = 0, $275 = 0, $276 = 0, $277 = 0, $278 = 0, $279 = 0, $28 = 0, $280 = 0, $281 = 0, $282 = 0, $283 = 0, $284 = 0, $285 = 0; var $286 = 0, $287 = 0, $288 = 0, $289 = 0, $29 = 0, $290 = 0, $291 = 0, $292 = 0, $293 = 0, $294 = 0, $295 = 0, $296 = 0, $297 = 0, $298 = 0, $299 = 0, $3 = 0, $30 = 0, $300 = 0, $301 = 0, $302 = 0; var $303 = 0, $304 = 0, $305 = 0, $306 = 0, $307 = 0, $308 = 0, $309 = 0, $31 = 0, $310 = 0, $311 = 0, $312 = 0, $313 = 0, $314 = 0, $315 = 0, $316 = 0, $317 = 0, $318 = 0, $319 = 0, $32 = 0, $320 = 0; var $321 = 0, $33 = 0, $34 = 0, $35 = 0, $36 = 0, $37 = 0, $38 = 0, $39 = 0, $4 = 0, $40 = 0, $41 = 0, $42 = 0, $43 = 0, $44 = 0, $45 = 0, $46 = 0, $47 = 0, $48 = 0, $49 = 0, $5 = 0; var $50 = 0, $51 = 0, $52 = 0, $53 = 0, $54 = 0, $55 = 0, $56 = 0, $57 = 0, $58 = 0, $59 = 0, $6 = 0, $60 = 0, $61 = 0, $62 = 0, $63 = 0, $64 = 0, $65 = 0, $66 = 0, $67 = 0, $68 = 0; var $69 = 0, $7 = 0, $70 = 0, $71 = 0, $72 = 0, $73 = 0, $74 = 0, $75 = 0, $76 = 0, $77 = 0, $78 = 0, $79 = 0, $8 = 0, $80 = 0, $81 = 0, $82 = 0, $83 = 0, $84 = 0, $85 = 0, $86 = 0; var $87 = 0, $88 = 0, $89 = 0, $9 = 0, $90 = 0, $91 = 0, $92 = 0, $93 = 0, $94 = 0, $95 = 0, $96 = 0, $97 = 0, $98 = 0, $99 = 0, $F16$0 = 0, $I18$0 = 0, $K19$052 = 0, $R$0 = 0, $R$0$lcssa = 0, $R$1 = 0; var $R7$0 = 0, $R7$0$lcssa = 0, $R7$1 = 0, $RP$0 = 0, $RP$0$lcssa = 0, $RP9$0 = 0, $RP9$0$lcssa = 0, $T$0$lcssa = 0, $T$051 = 0, $T$051$lcssa = 0, $cond = 0, $cond47 = 0, $not$ = 0, $p$0 = 0, $psize$0 = 0, $psize$1 = 0, $sp$0$i = 0, $sp$0$in$i = 0, label = 0, sp = 0; sp = STACKTOP; $0 = ($mem|0)==(0|0); if ($0) { return; } $1 = ((($mem)) + -8|0); $2 = HEAP32[(828)>>2]|0; $3 = ($1>>>0)<($2>>>0); if ($3) { _abort(); // unreachable; } $4 = ((($mem)) + -4|0); $5 = HEAP32[$4>>2]|0; $6 = $5 & 3; $7 = ($6|0)==(1); if ($7) { _abort(); // unreachable; } $8 = $5 & -8; $$sum = (($8) + -8)|0; $9 = (($mem) + ($$sum)|0); $10 = $5 & 1; $11 = ($10|0)==(0); do { if ($11) { $12 = HEAP32[$1>>2]|0; $13 = ($6|0)==(0); if ($13) { return; } $$sum2 = (-8 - ($12))|0; $14 = (($mem) + ($$sum2)|0); $15 = (($12) + ($8))|0; $16 = ($14>>>0)<($2>>>0); if ($16) { _abort(); // unreachable; } $17 = HEAP32[(832)>>2]|0; $18 = ($14|0)==($17|0); if ($18) { $$sum3 = (($8) + -4)|0; $103 = (($mem) + ($$sum3)|0); $104 = HEAP32[$103>>2]|0; $105 = $104 & 3; $106 = ($105|0)==(3); if (!($106)) { $p$0 = $14;$psize$0 = $15; break; } HEAP32[(820)>>2] = $15; $107 = $104 & -2; HEAP32[$103>>2] = $107; $108 = $15 | 1; $$sum20 = (($$sum2) + 4)|0; $109 = (($mem) + ($$sum20)|0); HEAP32[$109>>2] = $108; HEAP32[$9>>2] = $15; return; } $19 = $12 >>> 3; $20 = ($12>>>0)<(256); if ($20) { $$sum30 = (($$sum2) + 8)|0; $21 = (($mem) + ($$sum30)|0); $22 = HEAP32[$21>>2]|0; $$sum31 = (($$sum2) + 12)|0; $23 = (($mem) + ($$sum31)|0); $24 = HEAP32[$23>>2]|0; $25 = $19 << 1; $26 = (852 + ($25<<2)|0); $27 = ($22|0)==($26|0); if (!($27)) { $28 = ($22>>>0)<($2>>>0); if ($28) { _abort(); // unreachable; } $29 = ((($22)) + 12|0); $30 = HEAP32[$29>>2]|0; $31 = ($30|0)==($14|0); if (!($31)) { _abort(); // unreachable; } } $32 = ($24|0)==($22|0); if ($32) { $33 = 1 << $19; $34 = $33 ^ -1; $35 = HEAP32[812>>2]|0; $36 = $35 & $34; HEAP32[812>>2] = $36; $p$0 = $14;$psize$0 = $15; break; } $37 = ($24|0)==($26|0); if ($37) { $$pre60 = ((($24)) + 8|0); $$pre$phi61Z2D = $$pre60; } else { $38 = ($24>>>0)<($2>>>0); if ($38) { _abort(); // unreachable; } $39 = ((($24)) + 8|0); $40 = HEAP32[$39>>2]|0; $41 = ($40|0)==($14|0); if ($41) { $$pre$phi61Z2D = $39; } else { _abort(); // unreachable; } } $42 = ((($22)) + 12|0); HEAP32[$42>>2] = $24; HEAP32[$$pre$phi61Z2D>>2] = $22; $p$0 = $14;$psize$0 = $15; break; } $$sum22 = (($$sum2) + 24)|0; $43 = (($mem) + ($$sum22)|0); $44 = HEAP32[$43>>2]|0; $$sum23 = (($$sum2) + 12)|0; $45 = (($mem) + ($$sum23)|0); $46 = HEAP32[$45>>2]|0; $47 = ($46|0)==($14|0); do { if ($47) { $$sum25 = (($$sum2) + 20)|0; $57 = (($mem) + ($$sum25)|0); $58 = HEAP32[$57>>2]|0; $59 = ($58|0)==(0|0); if ($59) { $$sum24 = (($$sum2) + 16)|0; $60 = (($mem) + ($$sum24)|0); $61 = HEAP32[$60>>2]|0; $62 = ($61|0)==(0|0); if ($62) { $R$1 = 0; break; } else { $R$0 = $61;$RP$0 = $60; } } else { $R$0 = $58;$RP$0 = $57; } while(1) { $63 = ((($R$0)) + 20|0); $64 = HEAP32[$63>>2]|0; $65 = ($64|0)==(0|0); if (!($65)) { $R$0 = $64;$RP$0 = $63; continue; } $66 = ((($R$0)) + 16|0); $67 = HEAP32[$66>>2]|0; $68 = ($67|0)==(0|0); if ($68) { $R$0$lcssa = $R$0;$RP$0$lcssa = $RP$0; break; } else { $R$0 = $67;$RP$0 = $66; } } $69 = ($RP$0$lcssa>>>0)<($2>>>0); if ($69) { _abort(); // unreachable; } else { HEAP32[$RP$0$lcssa>>2] = 0; $R$1 = $R$0$lcssa; break; } } else { $$sum29 = (($$sum2) + 8)|0; $48 = (($mem) + ($$sum29)|0); $49 = HEAP32[$48>>2]|0; $50 = ($49>>>0)<($2>>>0); if ($50) { _abort(); // unreachable; } $51 = ((($49)) + 12|0); $52 = HEAP32[$51>>2]|0; $53 = ($52|0)==($14|0); if (!($53)) { _abort(); // unreachable; } $54 = ((($46)) + 8|0); $55 = HEAP32[$54>>2]|0; $56 = ($55|0)==($14|0); if ($56) { HEAP32[$51>>2] = $46; HEAP32[$54>>2] = $49; $R$1 = $46; break; } else { _abort(); // unreachable; } } } while(0); $70 = ($44|0)==(0|0); if ($70) { $p$0 = $14;$psize$0 = $15; } else { $$sum26 = (($$sum2) + 28)|0; $71 = (($mem) + ($$sum26)|0); $72 = HEAP32[$71>>2]|0; $73 = (1116 + ($72<<2)|0); $74 = HEAP32[$73>>2]|0; $75 = ($14|0)==($74|0); if ($75) { HEAP32[$73>>2] = $R$1; $cond = ($R$1|0)==(0|0); if ($cond) { $76 = 1 << $72; $77 = $76 ^ -1; $78 = HEAP32[(816)>>2]|0; $79 = $78 & $77; HEAP32[(816)>>2] = $79; $p$0 = $14;$psize$0 = $15; break; } } else { $80 = HEAP32[(828)>>2]|0; $81 = ($44>>>0)<($80>>>0); if ($81) { _abort(); // unreachable; } $82 = ((($44)) + 16|0); $83 = HEAP32[$82>>2]|0; $84 = ($83|0)==($14|0); if ($84) { HEAP32[$82>>2] = $R$1; } else { $85 = ((($44)) + 20|0); HEAP32[$85>>2] = $R$1; } $86 = ($R$1|0)==(0|0); if ($86) { $p$0 = $14;$psize$0 = $15; break; } } $87 = HEAP32[(828)>>2]|0; $88 = ($R$1>>>0)<($87>>>0); if ($88) { _abort(); // unreachable; } $89 = ((($R$1)) + 24|0); HEAP32[$89>>2] = $44; $$sum27 = (($$sum2) + 16)|0; $90 = (($mem) + ($$sum27)|0); $91 = HEAP32[$90>>2]|0; $92 = ($91|0)==(0|0); do { if (!($92)) { $93 = ($91>>>0)<($87>>>0); if ($93) { _abort(); // unreachable; } else { $94 = ((($R$1)) + 16|0); HEAP32[$94>>2] = $91; $95 = ((($91)) + 24|0); HEAP32[$95>>2] = $R$1; break; } } } while(0); $$sum28 = (($$sum2) + 20)|0; $96 = (($mem) + ($$sum28)|0); $97 = HEAP32[$96>>2]|0; $98 = ($97|0)==(0|0); if ($98) { $p$0 = $14;$psize$0 = $15; } else { $99 = HEAP32[(828)>>2]|0; $100 = ($97>>>0)<($99>>>0); if ($100) { _abort(); // unreachable; } else { $101 = ((($R$1)) + 20|0); HEAP32[$101>>2] = $97; $102 = ((($97)) + 24|0); HEAP32[$102>>2] = $R$1; $p$0 = $14;$psize$0 = $15; break; } } } } else { $p$0 = $1;$psize$0 = $8; } } while(0); $110 = ($p$0>>>0)<($9>>>0); if (!($110)) { _abort(); // unreachable; } $$sum19 = (($8) + -4)|0; $111 = (($mem) + ($$sum19)|0); $112 = HEAP32[$111>>2]|0; $113 = $112 & 1; $114 = ($113|0)==(0); if ($114) { _abort(); // unreachable; } $115 = $112 & 2; $116 = ($115|0)==(0); if ($116) { $117 = HEAP32[(836)>>2]|0; $118 = ($9|0)==($117|0); if ($118) { $119 = HEAP32[(824)>>2]|0; $120 = (($119) + ($psize$0))|0; HEAP32[(824)>>2] = $120; HEAP32[(836)>>2] = $p$0; $121 = $120 | 1; $122 = ((($p$0)) + 4|0); HEAP32[$122>>2] = $121; $123 = HEAP32[(832)>>2]|0; $124 = ($p$0|0)==($123|0); if (!($124)) { return; } HEAP32[(832)>>2] = 0; HEAP32[(820)>>2] = 0; return; } $125 = HEAP32[(832)>>2]|0; $126 = ($9|0)==($125|0); if ($126) { $127 = HEAP32[(820)>>2]|0; $128 = (($127) + ($psize$0))|0; HEAP32[(820)>>2] = $128; HEAP32[(832)>>2] = $p$0; $129 = $128 | 1; $130 = ((($p$0)) + 4|0); HEAP32[$130>>2] = $129; $131 = (($p$0) + ($128)|0); HEAP32[$131>>2] = $128; return; } $132 = $112 & -8; $133 = (($132) + ($psize$0))|0; $134 = $112 >>> 3; $135 = ($112>>>0)<(256); do { if ($135) { $136 = (($mem) + ($8)|0); $137 = HEAP32[$136>>2]|0; $$sum1718 = $8 | 4; $138 = (($mem) + ($$sum1718)|0); $139 = HEAP32[$138>>2]|0; $140 = $134 << 1; $141 = (852 + ($140<<2)|0); $142 = ($137|0)==($141|0); if (!($142)) { $143 = HEAP32[(828)>>2]|0; $144 = ($137>>>0)<($143>>>0); if ($144) { _abort(); // unreachable; } $145 = ((($137)) + 12|0); $146 = HEAP32[$145>>2]|0; $147 = ($146|0)==($9|0); if (!($147)) { _abort(); // unreachable; } } $148 = ($139|0)==($137|0); if ($148) { $149 = 1 << $134; $150 = $149 ^ -1; $151 = HEAP32[812>>2]|0; $152 = $151 & $150; HEAP32[812>>2] = $152; break; } $153 = ($139|0)==($141|0); if ($153) { $$pre58 = ((($139)) + 8|0); $$pre$phi59Z2D = $$pre58; } else { $154 = HEAP32[(828)>>2]|0; $155 = ($139>>>0)<($154>>>0); if ($155) { _abort(); // unreachable; } $156 = ((($139)) + 8|0); $157 = HEAP32[$156>>2]|0; $158 = ($157|0)==($9|0); if ($158) { $$pre$phi59Z2D = $156; } else { _abort(); // unreachable; } } $159 = ((($137)) + 12|0); HEAP32[$159>>2] = $139; HEAP32[$$pre$phi59Z2D>>2] = $137; } else { $$sum5 = (($8) + 16)|0; $160 = (($mem) + ($$sum5)|0); $161 = HEAP32[$160>>2]|0; $$sum67 = $8 | 4; $162 = (($mem) + ($$sum67)|0); $163 = HEAP32[$162>>2]|0; $164 = ($163|0)==($9|0); do { if ($164) { $$sum9 = (($8) + 12)|0; $175 = (($mem) + ($$sum9)|0); $176 = HEAP32[$175>>2]|0; $177 = ($176|0)==(0|0); if ($177) { $$sum8 = (($8) + 8)|0; $178 = (($mem) + ($$sum8)|0); $179 = HEAP32[$178>>2]|0; $180 = ($179|0)==(0|0); if ($180) { $R7$1 = 0; break; } else { $R7$0 = $179;$RP9$0 = $178; } } else { $R7$0 = $176;$RP9$0 = $175; } while(1) { $181 = ((($R7$0)) + 20|0); $182 = HEAP32[$181>>2]|0; $183 = ($182|0)==(0|0); if (!($183)) { $R7$0 = $182;$RP9$0 = $181; continue; } $184 = ((($R7$0)) + 16|0); $185 = HEAP32[$184>>2]|0; $186 = ($185|0)==(0|0); if ($186) { $R7$0$lcssa = $R7$0;$RP9$0$lcssa = $RP9$0; break; } else { $R7$0 = $185;$RP9$0 = $184; } } $187 = HEAP32[(828)>>2]|0; $188 = ($RP9$0$lcssa>>>0)<($187>>>0); if ($188) { _abort(); // unreachable; } else { HEAP32[$RP9$0$lcssa>>2] = 0; $R7$1 = $R7$0$lcssa; break; } } else { $165 = (($mem) + ($8)|0); $166 = HEAP32[$165>>2]|0; $167 = HEAP32[(828)>>2]|0; $168 = ($166>>>0)<($167>>>0); if ($168) { _abort(); // unreachable; } $169 = ((($166)) + 12|0); $170 = HEAP32[$169>>2]|0; $171 = ($170|0)==($9|0); if (!($171)) { _abort(); // unreachable; } $172 = ((($163)) + 8|0); $173 = HEAP32[$172>>2]|0; $174 = ($173|0)==($9|0); if ($174) { HEAP32[$169>>2] = $163; HEAP32[$172>>2] = $166; $R7$1 = $163; break; } else { _abort(); // unreachable; } } } while(0); $189 = ($161|0)==(0|0); if (!($189)) { $$sum12 = (($8) + 20)|0; $190 = (($mem) + ($$sum12)|0); $191 = HEAP32[$190>>2]|0; $192 = (1116 + ($191<<2)|0); $193 = HEAP32[$192>>2]|0; $194 = ($9|0)==($193|0); if ($194) { HEAP32[$192>>2] = $R7$1; $cond47 = ($R7$1|0)==(0|0); if ($cond47) { $195 = 1 << $191; $196 = $195 ^ -1; $197 = HEAP32[(816)>>2]|0; $198 = $197 & $196; HEAP32[(816)>>2] = $198; break; } } else { $199 = HEAP32[(828)>>2]|0; $200 = ($161>>>0)<($199>>>0); if ($200) { _abort(); // unreachable; } $201 = ((($161)) + 16|0); $202 = HEAP32[$201>>2]|0; $203 = ($202|0)==($9|0); if ($203) { HEAP32[$201>>2] = $R7$1; } else { $204 = ((($161)) + 20|0); HEAP32[$204>>2] = $R7$1; } $205 = ($R7$1|0)==(0|0); if ($205) { break; } } $206 = HEAP32[(828)>>2]|0; $207 = ($R7$1>>>0)<($206>>>0); if ($207) { _abort(); // unreachable; } $208 = ((($R7$1)) + 24|0); HEAP32[$208>>2] = $161; $$sum13 = (($8) + 8)|0; $209 = (($mem) + ($$sum13)|0); $210 = HEAP32[$209>>2]|0; $211 = ($210|0)==(0|0); do { if (!($211)) { $212 = ($210>>>0)<($206>>>0); if ($212) { _abort(); // unreachable; } else { $213 = ((($R7$1)) + 16|0); HEAP32[$213>>2] = $210; $214 = ((($210)) + 24|0); HEAP32[$214>>2] = $R7$1; break; } } } while(0); $$sum14 = (($8) + 12)|0; $215 = (($mem) + ($$sum14)|0); $216 = HEAP32[$215>>2]|0; $217 = ($216|0)==(0|0); if (!($217)) { $218 = HEAP32[(828)>>2]|0; $219 = ($216>>>0)<($218>>>0); if ($219) { _abort(); // unreachable; } else { $220 = ((($R7$1)) + 20|0); HEAP32[$220>>2] = $216; $221 = ((($216)) + 24|0); HEAP32[$221>>2] = $R7$1; break; } } } } } while(0); $222 = $133 | 1; $223 = ((($p$0)) + 4|0); HEAP32[$223>>2] = $222; $224 = (($p$0) + ($133)|0); HEAP32[$224>>2] = $133; $225 = HEAP32[(832)>>2]|0; $226 = ($p$0|0)==($225|0); if ($226) { HEAP32[(820)>>2] = $133; return; } else { $psize$1 = $133; } } else { $227 = $112 & -2; HEAP32[$111>>2] = $227; $228 = $psize$0 | 1; $229 = ((($p$0)) + 4|0); HEAP32[$229>>2] = $228; $230 = (($p$0) + ($psize$0)|0); HEAP32[$230>>2] = $psize$0; $psize$1 = $psize$0; } $231 = $psize$1 >>> 3; $232 = ($psize$1>>>0)<(256); if ($232) { $233 = $231 << 1; $234 = (852 + ($233<<2)|0); $235 = HEAP32[812>>2]|0; $236 = 1 << $231; $237 = $235 & $236; $238 = ($237|0)==(0); if ($238) { $239 = $235 | $236; HEAP32[812>>2] = $239; $$pre = (($233) + 2)|0; $$pre57 = (852 + ($$pre<<2)|0); $$pre$phiZ2D = $$pre57;$F16$0 = $234; } else { $$sum11 = (($233) + 2)|0; $240 = (852 + ($$sum11<<2)|0); $241 = HEAP32[$240>>2]|0; $242 = HEAP32[(828)>>2]|0; $243 = ($241>>>0)<($242>>>0); if ($243) { _abort(); // unreachable; } else { $$pre$phiZ2D = $240;$F16$0 = $241; } } HEAP32[$$pre$phiZ2D>>2] = $p$0; $244 = ((($F16$0)) + 12|0); HEAP32[$244>>2] = $p$0; $245 = ((($p$0)) + 8|0); HEAP32[$245>>2] = $F16$0; $246 = ((($p$0)) + 12|0); HEAP32[$246>>2] = $234; return; } $247 = $psize$1 >>> 8; $248 = ($247|0)==(0); if ($248) { $I18$0 = 0; } else { $249 = ($psize$1>>>0)>(16777215); if ($249) { $I18$0 = 31; } else { $250 = (($247) + 1048320)|0; $251 = $250 >>> 16; $252 = $251 & 8; $253 = $247 << $252; $254 = (($253) + 520192)|0; $255 = $254 >>> 16; $256 = $255 & 4; $257 = $256 | $252; $258 = $253 << $256; $259 = (($258) + 245760)|0; $260 = $259 >>> 16; $261 = $260 & 2; $262 = $257 | $261; $263 = (14 - ($262))|0; $264 = $258 << $261; $265 = $264 >>> 15; $266 = (($263) + ($265))|0; $267 = $266 << 1; $268 = (($266) + 7)|0; $269 = $psize$1 >>> $268; $270 = $269 & 1; $271 = $270 | $267; $I18$0 = $271; } } $272 = (1116 + ($I18$0<<2)|0); $273 = ((($p$0)) + 28|0); HEAP32[$273>>2] = $I18$0; $274 = ((($p$0)) + 16|0); $275 = ((($p$0)) + 20|0); HEAP32[$275>>2] = 0; HEAP32[$274>>2] = 0; $276 = HEAP32[(816)>>2]|0; $277 = 1 << $I18$0; $278 = $276 & $277; $279 = ($278|0)==(0); L199: do { if ($279) { $280 = $276 | $277; HEAP32[(816)>>2] = $280; HEAP32[$272>>2] = $p$0; $281 = ((($p$0)) + 24|0); HEAP32[$281>>2] = $272; $282 = ((($p$0)) + 12|0); HEAP32[$282>>2] = $p$0; $283 = ((($p$0)) + 8|0); HEAP32[$283>>2] = $p$0; } else { $284 = HEAP32[$272>>2]|0; $285 = ((($284)) + 4|0); $286 = HEAP32[$285>>2]|0; $287 = $286 & -8; $288 = ($287|0)==($psize$1|0); L202: do { if ($288) { $T$0$lcssa = $284; } else { $289 = ($I18$0|0)==(31); $290 = $I18$0 >>> 1; $291 = (25 - ($290))|0; $292 = $289 ? 0 : $291; $293 = $psize$1 << $292; $K19$052 = $293;$T$051 = $284; while(1) { $300 = $K19$052 >>> 31; $301 = (((($T$051)) + 16|0) + ($300<<2)|0); $296 = HEAP32[$301>>2]|0; $302 = ($296|0)==(0|0); if ($302) { $$lcssa = $301;$T$051$lcssa = $T$051; break; } $294 = $K19$052 << 1; $295 = ((($296)) + 4|0); $297 = HEAP32[$295>>2]|0; $298 = $297 & -8; $299 = ($298|0)==($psize$1|0); if ($299) { $T$0$lcssa = $296; break L202; } else { $K19$052 = $294;$T$051 = $296; } } $303 = HEAP32[(828)>>2]|0; $304 = ($$lcssa>>>0)<($303>>>0); if ($304) { _abort(); // unreachable; } else { HEAP32[$$lcssa>>2] = $p$0; $305 = ((($p$0)) + 24|0); HEAP32[$305>>2] = $T$051$lcssa; $306 = ((($p$0)) + 12|0); HEAP32[$306>>2] = $p$0; $307 = ((($p$0)) + 8|0); HEAP32[$307>>2] = $p$0; break L199; } } } while(0); $308 = ((($T$0$lcssa)) + 8|0); $309 = HEAP32[$308>>2]|0; $310 = HEAP32[(828)>>2]|0; $311 = ($309>>>0)>=($310>>>0); $not$ = ($T$0$lcssa>>>0)>=($310>>>0); $312 = $311 & $not$; if ($312) { $313 = ((($309)) + 12|0); HEAP32[$313>>2] = $p$0; HEAP32[$308>>2] = $p$0; $314 = ((($p$0)) + 8|0); HEAP32[$314>>2] = $309; $315 = ((($p$0)) + 12|0); HEAP32[$315>>2] = $T$0$lcssa; $316 = ((($p$0)) + 24|0); HEAP32[$316>>2] = 0; break; } else { _abort(); // unreachable; } } } while(0); $317 = HEAP32[(844)>>2]|0; $318 = (($317) + -1)|0; HEAP32[(844)>>2] = $318; $319 = ($318|0)==(0); if ($319) { $sp$0$in$i = (1268); } else { return; } while(1) { $sp$0$i = HEAP32[$sp$0$in$i>>2]|0; $320 = ($sp$0$i|0)==(0|0); $321 = ((($sp$0$i)) + 8|0); if ($320) { break; } else { $sp$0$in$i = $321; } } HEAP32[(844)>>2] = -1; return; } function runPostSets() { } function _memset(ptr, value, num) { ptr = ptr|0; value = value|0; num = num|0; var stop = 0, value4 = 0, stop4 = 0, unaligned = 0; stop = (ptr + num)|0; if ((num|0) >= 20) { // This is unaligned, but quite large, so work hard to get to aligned settings value = value & 0xff; unaligned = ptr & 3; value4 = value | (value << 8) | (value << 16) | (value << 24); stop4 = stop & ~3; if (unaligned) { unaligned = (ptr + 4 - unaligned)|0; while ((ptr|0) < (unaligned|0)) { // no need to check for stop, since we have large num HEAP8[((ptr)>>0)]=value; ptr = (ptr+1)|0; } } while ((ptr|0) < (stop4|0)) { HEAP32[((ptr)>>2)]=value4; ptr = (ptr+4)|0; } } while ((ptr|0) < (stop|0)) { HEAP8[((ptr)>>0)]=value; ptr = (ptr+1)|0; } return (ptr-num)|0; } function _memcpy(dest, src, num) { dest = dest|0; src = src|0; num = num|0; var ret = 0; if ((num|0) >= 4096) return _emscripten_memcpy_big(dest|0, src|0, num|0)|0; ret = dest|0; if ((dest&3) == (src&3)) { while (dest & 3) { if ((num|0) == 0) return ret|0; HEAP8[((dest)>>0)]=((HEAP8[((src)>>0)])|0); dest = (dest+1)|0; src = (src+1)|0; num = (num-1)|0; } while ((num|0) >= 4) { HEAP32[((dest)>>2)]=((HEAP32[((src)>>2)])|0); dest = (dest+4)|0; src = (src+4)|0; num = (num-4)|0; } } while ((num|0) > 0) { HEAP8[((dest)>>0)]=((HEAP8[((src)>>0)])|0); dest = (dest+1)|0; src = (src+1)|0; num = (num-1)|0; } return ret|0; } function dynCall_vi(index,a1) { index = index|0; a1=a1|0; FUNCTION_TABLE_vi[index&7](a1|0); } function dynCall_viii(index,a1,a2,a3) { index = index|0; a1=a1|0; a2=a2|0; a3=a3|0; FUNCTION_TABLE_viii[index&15](a1|0,a2|0,a3|0); } function b0(p0) { p0 = p0|0; nullFunc_vi(0); } function b1(p0,p1,p2) { p0 = p0|0;p1 = p1|0;p2 = p2|0; nullFunc_viii(1); } // EMSCRIPTEN_END_FUNCS var FUNCTION_TABLE_vi = [b0,b0,_TextBox_paint,_Button_paint,b0,_Window_paint_handler,b0,_Desktop_paint_handler]; var FUNCTION_TABLE_viii = [b1,_Calculator_button_handler,b1,b1,_Button_mousedown_handler,b1,_Window_mousedown_handler,b1,_spawn_calculator,_main_mouse_callback,b1,b1,b1,b1,b1,b1]; return { _free: _free, _fake_os_doMouseCallback: _fake_os_doMouseCallback, _memset: _memset, _malloc: _malloc, _memcpy: _memcpy, ___errno_location: ___errno_location, _main: _main, runPostSets: runPostSets, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, establishStackSpace: establishStackSpace, setThrew: setThrew, setTempRet0: setTempRet0, getTempRet0: getTempRet0, dynCall_vi: dynCall_vi, dynCall_viii: dynCall_viii }; }) // EMSCRIPTEN_END_ASM (Module.asmGlobalArg, Module.asmLibraryArg, buffer); var real__free = asm["_free"]; asm["_free"] = function() { assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)'); assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)'); return real__free.apply(null, arguments); }; var real__fake_os_doMouseCallback = asm["_fake_os_doMouseCallback"]; asm["_fake_os_doMouseCallback"] = function() { assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)'); assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)'); return real__fake_os_doMouseCallback.apply(null, arguments); }; var real__malloc = asm["_malloc"]; asm["_malloc"] = function() { assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)'); assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)'); return real__malloc.apply(null, arguments); }; var real____errno_location = asm["___errno_location"]; asm["___errno_location"] = function() { assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)'); assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)'); return real____errno_location.apply(null, arguments); }; var real__main = asm["_main"]; asm["_main"] = function() { assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)'); assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)'); return real__main.apply(null, arguments); }; var _free = Module["_free"] = asm["_free"]; var _fake_os_doMouseCallback = Module["_fake_os_doMouseCallback"] = asm["_fake_os_doMouseCallback"]; 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 ___errno_location = Module["___errno_location"] = asm["___errno_location"]; var _main = Module["_main"] = asm["_main"]; var dynCall_vi = Module["dynCall_vi"] = asm["dynCall_vi"]; var dynCall_viii = Module["dynCall_viii"] = asm["dynCall_viii"]; ; Runtime.stackAlloc = asm['stackAlloc']; Runtime.stackSave = asm['stackSave']; Runtime.stackRestore = asm['stackRestore']; Runtime.establishStackSpace = asm['establishStackSpace']; Runtime.setTempRet0 = asm['setTempRet0']; Runtime.getTempRet0 = asm['getTempRet0']; // === Auto-generated postamble setup entry stuff === 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 run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false) if (!Module['calledRun']) run(); if (!Module['calledRun']) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled } 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; i < argc-1; i = i + 1) { argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL)); pad(); } argv.push(0); argv = allocate(argv, 'i32', ALLOC_NORMAL); try { var ret = Module['_main'](argc, argv, 0); // if we're not running an evented main loop, it's time to exit exit(ret, /* implicit = */ true); } catch(e) { if (e instanceof ExitStatus) { // exit() throws this once it's done to make sure execution // has been stopped completely return; } else if (e == 'SimulateInfiniteLoop') { // running an evented main loop, don't immediately exit Module['noExitRuntime'] = true; return; } else { if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]); throw e; } } finally { calledMain = true; } } function run(args) { args = args || Module['arguments']; if (preloadStartTime === null) preloadStartTime = Date.now(); if (runDependencies > 0) { Module.printErr('run() called, but dependencies remain, so not running'); return; } preRun(); if (runDependencies > 0) return; // a preRun added a dependency, run will be called later if (Module['calledRun']) return; // run may have just been called through dependencies being fulfilled just in this very frame function doRun() { if (Module['calledRun']) return; // run may have just been called while the async setStatus time below was happening Module['calledRun'] = true; if (ABORT) return; ensureInitRuntime(); preMain(); if (ENVIRONMENT_IS_WEB && preloadStartTime !== null) { Module.printErr('pre-main prep time: ' + (Date.now() - preloadStartTime) + ' ms'); } 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']) { Module.printErr('exit(' + status + ') implicitly called by end of main(), but noExitRuntime, so not exiting the runtime (you can use emscripten_force_exit, if you want to force a true shutdown)'); return; } if (Module['noExitRuntime']) { Module.printErr('exit(' + status + ') called, but noExitRuntime, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)'); } else { ABORT = true; EXITSTATUS = status; STACKTOP = initialStackTop; exitRuntime(); if (Module['onExit']) Module['onExit'](status); } if (ENVIRONMENT_IS_NODE) { // Work around a node.js bug where stdout buffer is not flushed at process exit: // Instead of process.exit() directly, wait for stdout flush event. // See https://github.com/joyent/node/issues/1669 and https://github.com/kripken/emscripten/issues/2582 // Workaround is based on https://github.com/RReverser/acorn/commit/50ab143cecc9ed71a2d66f78b4aec3bb2e9844f6 process['stdout']['once']('drain', function () { process['exit'](status); }); console.log(' '); // Make sure to print something to force the drain event to occur, in case the stdout buffer was empty. // Work around another node bug where sometimes 'drain' is never fired - make another effort // to emit the exit status, after a significant delay (if node hasn't fired drain by then, give up) setTimeout(function() { process['exit'](status); }, 500); } else if (ENVIRONMENT_IS_SHELL && typeof quit === 'function') { quit(status); } // if we reach here, we must throw an exception to halt the current execution 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 = ''; var output = 'abort(' + what + ') at ' + stackTrace() + extra; if (abortDecorators) { abortDecorators.forEach(function(decorator) { output = decorator(output, what); }); } throw output; } Module['abort'] = Module.abort = abort; // {{PRE_RUN_ADDITIONS}} if (Module['preInit']) { if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']]; while (Module['preInit'].length > 0) { Module['preInit'].pop()(); } } // shouldRunNow refers to calling main(), not run(). var shouldRunNow = true; if (Module['noInitialRun']) { shouldRunNow = false; } Module["noExitRuntime"] = true; run(); // {{POST_RUN_ADDITIONS}} // {{MODULE_ADDITIONS}}
'use strict'; module.exports = { conditions: [''], name: 'RegularExpressionClassChars', rules: ['RegularExpressionClassChar', 'RegularExpressionClassChars RegularExpressionClassChar'], handlers: ['$$ = $1', '$$ = $1 + $2'], subRules: [require('./RegularExpressionClassChar')] };
const user = require("./models/User"); user .findAll() .then(data => console.log(data)) .catch(err => console.log(err)); user.create()
"use strict"; require('./queryBuilder.service'); var orchestratorObject_1 = require('./core/orchestratorObject'); var queryTranspiler_1 = require('./core/queryTranspiler'); var objects_1 = require('./models/objects'); var widgets; (function (widgets) { 'use strict'; var QueryBuilderController = (function () { function QueryBuilderController($rootScope, $scope, $timeout, QueryBuilderService) { this.$rootScope = $rootScope; this.$timeout = $timeout; this.QueryBuilderService = QueryBuilderService; this.$scope = $scope; this.orchestrator = new orchestratorObject_1.query.core.Orchestrator(this.$scope.model); this.queryTranspiler = new queryTranspiler_1.transpiler.core.ESQueryTranspiler(); this.updateInputState(objects_1.QueryState.DO, true); this.instanceOrchestrator(); } QueryBuilderController.prototype.instanceOrchestrator = function () { var _this = this; if (!this.$scope.queryValue) return; this.shouldSearch = true; this.selected = this.$scope.queryValue.map(function (x) { return x.text; }).join(' '); this.$scope.queryValue.forEach(function (x) { _this.orchestrator.addTerm(x.text); }); this.updateParentData(); }; QueryBuilderController.prototype.filterText = function (value) { return this.QueryBuilderService.filterText(this.orchestrator, value); }; QueryBuilderController.prototype.setNextState = function (value, position, shouldSearch) { this.shouldSearch = this.QueryBuilderService.validShouldSearch(shouldSearch, this.orchestrator.getIsOrderBy(), this.orchestrator.getCurrentState()); this.setCurrentPosition(position); this.addNextTerm(value, position); }; QueryBuilderController.prototype.bindAllModel = function (item, $event) { var modelResult = this.QueryBuilderService.bindAllModel(this.orchestrator, $event.target.value, item, $event.target.selectionStart); this.selected = modelResult.value; $event.target.selectionStart = modelResult.position; this.setNextState(item, modelResult.position, false); }; QueryBuilderController.prototype.handleQueryPasted = function ($event) { var _this = this; this.$timeout(function () { _this.QueryBuilderService.handleCopiedText($event.target, _this.orchestrator); _this.setCurrentPosition($event.target.selectionStart); _this.updateInputState(objects_1.QueryState.DO); }); }; QueryBuilderController.prototype.getNextTerms = function ($viewValue) { return this.QueryBuilderService.getNextTerms(this.currentPosition, this.currentValue, this.orchestrator); }; QueryBuilderController.prototype.deleteAllFragments = function () { this.orchestrator.removeAllTerms(); this.updateInputState(objects_1.QueryState.DO, true); this.setTableViewQuery(null); this.QueryBuilderService.resetReplaceEvent(); }; QueryBuilderController.prototype.keyValidations = function (info) { this.detectQueryChanges(info); this.validStatusQuery(info); }; QueryBuilderController.prototype.setDeleteStatement = function (info) { this.currentValue = info.field.value; this.setCurrentPosition(info.field.selectionStart); if (info.field.selectionStart === 0) this.deleteAllFragments(); this.QueryBuilderService.resetTermsWhenDeletePerformed(info, this.orchestrator); }; QueryBuilderController.prototype.setStatusValidity = function (info) { return this.QueryBuilderService.validStatus(info, this.orchestrator); }; QueryBuilderController.prototype.setTypedQuery = function (value) { this.QueryBuilderService.resetTypedQuery(value); }; QueryBuilderController.prototype.setCursorPositionWhenRange = function (info) { return this.QueryBuilderService.getSimpleQuotesFromRange(this.orchestrator, info); }; QueryBuilderController.prototype.getCursorPosition = function ($event) { this.setCurrentPosition($event.target.selectionStart); }; QueryBuilderController.prototype.setTableViewRawQuery = function (query) { if (this.$scope.tableView) { this.$scope.tableView.setRawQuery(query); } }; QueryBuilderController.prototype.validStatusQuery = function (info) { this.setCurrentPosition(info.field.selectionStart); if (this.QueryBuilderService.validStatusQuery(info, this.orchestrator, this.currentPosition)) this.updateInputState(objects_1.QueryState.DO, true); else this.updateInputState(objects_1.QueryState.WRITING); }; QueryBuilderController.prototype.detectQueryChanges = function (info) { this.QueryBuilderService.detectQueryChanges(info, this.orchestrator); }; QueryBuilderController.prototype.updateInputState = function (state, isValid) { var _this = this; if (isValid === void 0) { isValid = this.orchestrator.isValidQuery(); } this.$timeout(function () { _this.current = _this.QueryBuilderService.updateQueryState(state, isValid); }); }; QueryBuilderController.prototype.addNextTerm = function (value, position) { if (this.QueryBuilderService.addNextTerm(value, position, this.orchestrator, false)) { this.updateQueryState(objects_1.QueryState.DO); } this.updateInputState(objects_1.QueryState.DO); }; QueryBuilderController.prototype.setCurrentPosition = function (position) { this.currentPosition = position; }; QueryBuilderController.prototype.updateQueryState = function (state) { if (state === objects_1.QueryState.DO && this.orchestrator.isValidQuery()) this.updateParentData(); this.updateInputState(state); }; QueryBuilderController.prototype.updateParentData = function () { if (!this.shouldSearch) return; this.QueryBuilderService.handleOpenWindow(this.$scope.openNewWindow, this.$scope.onBeforeOpenNewWindow); this.setTableViewQuery(this.queryTranspiler.transpileQuery(this.orchestrator.getQuery())); }; QueryBuilderController.prototype.reloadParentData = function (firstDelete) { if (!this.orchestrator.isValidQuery() && !firstDelete) return; this.setTableViewQuery(firstDelete || this.orchestrator.getQuery().length === 2 ? null : this.queryTranspiler.transpileQuery(this.orchestrator.getQuery())); }; QueryBuilderController.prototype.setTableViewQuery = function (query) { if (this.$scope.tableView) { this.$rootScope.$broadcast('ShowColumnsFromQueryBuilder', this.orchestrator.getQuery()); this.$scope.tableView.setQuery(query); this.resetSortIndicator(); if (!query) { this.$rootScope.$broadcast('ShowHideColumns'); this.setTableViewRawQuery(undefined); } else { this.setTableViewRawQuery(this.orchestrator.getQuery().slice()); } } }; QueryBuilderController.prototype.resetSortIndicator = function () { var _this = this; this.$timeout(function () { if (_this.orchestrator.getIsOrderBy()) { _this.$scope.tableView.clearSorts(); } else { _this.$scope.tableView.setDefaultSort(); } }); }; QueryBuilderController.$inject = ["$rootScope", "$scope", "$timeout", "QueryBuilderService"]; return QueryBuilderController; }()); angular .module(CPALS.modules.directives.MAIN) .controller('QueryBuilderController', QueryBuilderController); })(widgets || (widgets = {})); //# sourceMappingURL=queryBuilder.controller.js.map
import * as React from 'react' export default function Button() { return <button>button</button> }
import React, { Component } from 'react' import Cropper from 'cropperjs' import './style.scss' class Editor extends Component { constructor(props) { super(props) this.image = React.createRef() } start = () => { const { data, update } = this.props if (data.cropped || this.cropper) { return } this.cropper = new Cropper(this.image.current, { autoCrop: false, dragMode: 'move', background: false, ready: () => { if (data.croppedData) { this.cropper .crop() .setData(data.croppedData) .setCanvasData(data.canvasData) .setCropBoxData(data.cropBoxData) update({ croppedData: null, canvasData: null, cropBoxData: null, }) } }, crop: ({ detail }) => { if (detail.width > 0 && detail.height > 0 && !data.cropping) { update({ cropping: true, }) } }, }) } stop = () => { if (this.cropper) { this.cropper.destroy() this.cropper = null } } crop = () => { const { cropper } = this const { data, update } = this.props if (data.cropping) { data.croppedData = cropper.getData() data.canvasData = cropper.getCanvasData() data.cropBoxData = cropper.getCropBoxData() update({ cropped: true, cropping: false, previousUrl: data.url, url: cropper .getCroppedCanvas( data.type === 'image/png' ? {} : { fillColor: '#fff', }, ) .toDataURL(data.type), }) this.stop() } } clear = () => { const { data, update } = this.props if (data.cropping) { this.cropper.clear() update({ cropping: false, }) } } restore = () => { const { data, update } = this.props if (data.cropped) { update({ cropped: false, previousUrl: '', url: data.previousUrl, }) } } reset = () => { const { update } = this.props this.stop() update({ cropped: false, cropping: false, loaded: false, name: '', previousUrl: '', type: '', url: '', }) } onClick = ({ target }) => { const { cropper } = this const action = target.getAttribute('data-action') || target.parentElement.getAttribute('data-action') || target.parentElement.parentElement.getAttribute('data-action') || target.parentElement.parentElement.parentElement.getAttribute('data-action') switch (action) { case 'move': case 'crop': cropper.setDragMode(action) break case 'zoom-in': cropper.zoom(0.1) break case 'zoom-out': cropper.zoom(-0.1) break case 'rotate-left': cropper.rotate(-90) break case 'rotate-right': cropper.rotate(90) break case 'flip-horizontal': cropper.scaleX(-cropper.getData().scaleX || -1) break case 'flip-vertical': cropper.scaleY(-cropper.getData().scaleY || -1) break default: } } render() { const { data } = this.props return ( <div className="cropperEditor"> <div className="cropperCanvas" dblclick={this.dblclick}> <img ref={this.image} alt={data.name} src={data.url} onLoadStart={this.start.bind(this)} onLoad={this.start.bind(this)} /> </div> <div className="cropperToolbar" onClick={this.onClick.bind(this)}> <button className="cropperToolbar__button" data-action="move" title="Move (M)"> <span> <i className="fa fa-arrows-alt" aria-hidden="true"></i> </span> </button> <button className="cropperToolbar__button" data-action="crop" title="Crop (C)"> <span> <i className="fa fa-crop" aria-hidden="true"></i> </span> </button> <button className="cropperToolbar__button" data-action="zoom-in" title="Zoom In (I)"> <span> <i className="fa fa-search-plus" aria-hidden="true"></i> </span> </button> <button className="cropperToolbar__button" data-action="zoom-out" title="Zoom Out (O)"> <span> <i className="fa fa-search-minus" aria-hidden="true"></i> </span> </button> <button className="cropperToolbar__button" data-action="rotate-left" title="Rotate Left (L)" > <span> <i className="fa fa-undo" aria-hidden="true"></i> </span> </button> <button className="cropperToolbar__button" data-action="rotate-right" title="Rotate Right (R)" > <span> <i className="fa fa-repeat" aria-hidden="true"></i> </span> </button> <button className="cropperToolbar__button" data-action="flip-horizontal" title="Flip Horizontal (H)" > <span> <i className="fa fa-arrows-h" aria-hidden="true"></i> </span> </button> <button className="cropperToolbar__button" data-action="flip-vertical" title="Flip Vertical (V)" > <span> <i className="fa fa-arrows-v" aria-hidden="true"></i> </span> </button> </div> </div> ) } } export default Editor
/*! * ws: a node.js websocket client * Copyright(c) 2011 Einar Otto Stangvik <[email protected]> * MIT Licensed */ var events = require('events') , util = require('util') , EventEmitter = events.EventEmitter; /** * Hixie Sender implementation */ function Sender(socket) { if (this instanceof Sender === false) { throw new TypeError("Classes can't be function-called"); } events.EventEmitter.call(this); this.socket = socket; this.continuationFrame = false; this.isClosed = false; } module.exports = Sender; /** * Inherits from EventEmitter. */ util.inherits(Sender, events.EventEmitter); /** * Frames and writes data. * * @api public */ Sender.prototype.send = function(data, options, cb) { if (this.isClosed) return; var isString = typeof data == 'string' , length = isString ? Buffer.byteLength(data) : data.length , lengthbytes = (length > 127) ? 2 : 1 // assume less than 2**14 bytes , writeStartMarker = this.continuationFrame == false , writeEndMarker = !options || !(typeof options.fin != 'undefined' && !options.fin) , buffer = new Buffer((writeStartMarker ? ((options && options.binary) ? (1 + lengthbytes) : 1) : 0) + length + ((writeEndMarker && !(options && options.binary)) ? 1 : 0)) , offset = writeStartMarker ? 1 : 0; if (writeStartMarker) { if (options && options.binary) { buffer.write('\x80', 'binary'); // assume length less than 2**14 bytes if (lengthbytes > 1) buffer.write(String.fromCharCode(128+length/128), offset++, 'binary'); buffer.write(String.fromCharCode(length&0x7f), offset++, 'binary'); } else buffer.write('\x00', 'binary'); } if (isString) buffer.write(data, offset, 'utf8'); else data.copy(buffer, offset, 0); if (writeEndMarker) { if (options && options.binary) { // sending binary, not writing end marker } else buffer.write('\xff', offset + length, 'binary'); this.continuationFrame = false; } else this.continuationFrame = true; try { this.socket.write(buffer, 'binary', cb); } catch (e) { this.error(e.toString()); } }; /** * Sends a close instruction to the remote party. * * @api public */ Sender.prototype.close = function(code, data, mask, cb) { if (this.isClosed) return; this.isClosed = true; try { if (this.continuationFrame) this.socket.write(new Buffer([0xff], 'binary')); this.socket.write(new Buffer([0xff, 0x00]), 'binary', cb); } catch (e) { this.error(e.toString()); } }; /** * Sends a ping message to the remote party. Not available for hixie. * * @api public */ Sender.prototype.ping = function(data, options) {}; /** * Sends a pong message to the remote party. Not available for hixie. * * @api public */ Sender.prototype.pong = function(data, options) {}; /** * Handles an error * * @api private */ Sender.prototype.error = function (reason) { this.emit('error', reason); return this; };
'use strict'; var path = require('path') var webpack = require('webpack') var env = process.env.NODE_ENV var node_modules_dir = path.resolve(__dirname, 'node_modules'); var config = { output: { path: path.join(__dirname, 'dist/'), // filename: '[name].js', library: 'RedaxtorSeo', libraryTarget: 'umd' }, plugins: [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(env) }) ], module: { loaders: [ { test: /\.(js|jsx)$/, loader: 'babel', query: { presets: ['es2015', 'react'], plugins: [ 'babel-plugin-transform-object-rest-spread', 'babel-plugin-transform-class-properties'//used in material-ui ] } }, { test: /\.less$/, loader: "style!css?-url!less"//don't use loaders for urls } ], noParse: [] }, resolve: { extensions: ['', '.js', '.jsx'], alias: { react: path.resolve(node_modules_dir, 'react') } }, devtool: "source-map" // devtool: "eval-cheap-source-map" } if (env === 'production') { config.plugins.push( new webpack.optimize.UglifyJsPlugin({ compressor: { pure_getters: true, unsafe: true, unsafe_comps: true, screw_ie8: true, warnings: false } }) ) } module.exports = config
from flask_wtf import FlaskForm from wtforms import StringField, validators # Lomake roolia varten class RooliForm(FlaskForm): name = StringField("Nimi:", [validators.Length(min=2, max=20)]) class Meta: csrf = False